@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * |
597 | 597 | * @param string $url The URL to request. |
598 | 598 | * @param array $args Arguments to be posted with the request. |
599 | - * @return object An object containing details about this request. |
|
599 | + * @return string An object containing details about this request. |
|
600 | 600 | */ |
601 | 601 | private function _request( $url, $args = array() ) { |
602 | 602 | // Prefix the full pod URL if necessary. |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | * @see WP_Error::__construct() |
666 | 666 | * @since 1.6.0 |
667 | 667 | * |
668 | - * @param string|int $code Error code. |
|
668 | + * @param string $code Error code. |
|
669 | 669 | * @param string $message Error message. |
670 | 670 | * @param mixed $data Error data. |
671 | 671 | */ |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | switch ( $type ) { |
572 | 572 | case 'aspects': |
573 | 573 | // Add the 'public' aspect, as it's global and not user specific. |
574 | - $list['public'] = __( 'Public', 'wp-to-diaspora' ); |
|
574 | + $list[ 'public' ] = __( 'Public', 'wp-to-diaspora' ); |
|
575 | 575 | |
576 | 576 | // Add all user specific aspects. |
577 | 577 | foreach ( $raw_list as $aspect ) { |
@@ -615,12 +615,12 @@ discard block |
||
615 | 615 | // If the certificate bundle has been downloaded manually, use that instead. |
616 | 616 | // NOTE: This should actually never be necessary, it's a fallback! |
617 | 617 | if ( file_exists( WP2D_DIR . '/cacert.pem' ) ) { |
618 | - $defaults['sslcertificates'] = WP2D_DIR . '/cacert.pem'; |
|
618 | + $defaults[ 'sslcertificates' ] = WP2D_DIR . '/cacert.pem'; |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | // Set the correct cookie. |
622 | 622 | if ( ! empty( $this->_cookies ) ) { |
623 | - $defaults['cookies'] = $this->_cookies; |
|
623 | + $defaults[ 'cookies' ] = $this->_cookies; |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | $args = wp_parse_args( $args, $defaults ); |
@@ -651,8 +651,8 @@ discard block |
||
651 | 651 | } |
652 | 652 | |
653 | 653 | // Save the latest cookies. |
654 | - if ( isset( $response['cookies'] ) ) { |
|
655 | - $this->_cookies = $response['cookies']; |
|
654 | + if ( isset( $response[ 'cookies' ] ) ) { |
|
655 | + $this->_cookies = $response[ 'cookies' ]; |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | // Return the last request details. |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | /** |
738 | 738 | * Validate checkboxes, make them either true or false. |
739 | 739 | * |
740 | - * @param string|array $checkboxes Checkboxes to validate. |
|
740 | + * @param string[] $checkboxes Checkboxes to validate. |
|
741 | 741 | * @param array $options Options values themselves. |
742 | 742 | * @return array The validated options. |
743 | 743 | */ |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | /** |
752 | 752 | * Validate single-select fields and make sure their selected value are valid. |
753 | 753 | * |
754 | - * @param string|array $selects Name(s) of the select fields. |
|
754 | + * @param string $selects Name(s) of the select fields. |
|
755 | 755 | * @param array $options Options values themselves. |
756 | 756 | * @return array The validated options. |
757 | 757 | */ |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | /** |
768 | 768 | * Validate multi-select fields and make sure their selected values are valid. |
769 | 769 | * |
770 | - * @param string|array $selects Name(s) of the select fields. |
|
770 | + * @param string $selects Name(s) of the select fields. |
|
771 | 771 | * @param array $options Options values themselves. |
772 | 772 | * @return array The validated options. |
773 | 773 | */ |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | * Validate the passed aspects or services. |
822 | 822 | * |
823 | 823 | * @param array $aspects_services List of aspects or services that need to be validated. |
824 | - * @param array $default Default value if not valid. |
|
824 | + * @param string[] $default Default value if not valid. |
|
825 | 825 | * @return array The validated list of aspects or services. |
826 | 826 | */ |
827 | 827 | public function validate_aspects_services( &$aspects_services, $default = array() ) { |
@@ -435,8 +435,11 @@ discard block |
||
435 | 435 | if ( 'settings_page_wp_to_diaspora' === get_current_screen()->id ) : ?> |
436 | 436 | <label><?php echo $checkbox; ?><?php esc_html_e( 'Yes' ); ?></label> |
437 | 437 | <p class="description"><?php echo esc_html( $description ); ?></p> |
438 | - <?php else : ?> |
|
439 | - <label title="<?php echo esc_attr( $description ); ?>"><?php echo $checkbox; ?><?php esc_html_e( 'Show "Posted at" link?', 'wp-to-diaspora' ); ?></label> |
|
438 | + <?php else { |
|
439 | + : ?> |
|
440 | + <label title="<?php echo esc_attr( $description ); |
|
441 | +} |
|
442 | +?>"><?php echo $checkbox; ?><?php esc_html_e( 'Show "Posted at" link?', 'wp-to-diaspora' ); ?></label> |
|
440 | 443 | <?php endif; |
441 | 444 | } |
442 | 445 | |
@@ -474,9 +477,11 @@ discard block |
||
474 | 477 | |
475 | 478 | <?php if ( $on_settings_page ) : ?> |
476 | 479 | <p class="description"><?php echo esc_html( $description ); ?></p> |
477 | - <?php else : ?> |
|
480 | + <?php else { |
|
481 | + : ?> |
|
478 | 482 | </label> |
479 | 483 | <?php endif; |
484 | +} |
|
480 | 485 | } |
481 | 486 | |
482 | 487 | /** |
@@ -558,8 +563,11 @@ discard block |
||
558 | 563 | <?php foreach ( $list as $id => $name ) : ?> |
559 | 564 | <label><input type="checkbox" name="wp_to_diaspora_settings[<?php echo esc_attr( $type ); ?>][]" value="<?php echo esc_attr( $id ); ?>" <?php checked( in_array( $id, $items ) ); ?>><?php echo esc_html( $name ); ?></label> |
560 | 565 | <?php endforeach; ?> |
561 | - <?php else : ?> |
|
562 | - <label><?php echo $empty_label; ?></label> |
|
566 | + <?php else { |
|
567 | + : ?> |
|
568 | + <label><?php echo $empty_label; |
|
569 | +} |
|
570 | +?></label> |
|
563 | 571 | <?php endif; ?> |
564 | 572 | </div> |
565 | 573 | <p class="description"> |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @return string Return the currently selected tab. |
105 | 105 | */ |
106 | 106 | private function _current_tab( $default = 'defaults' ) { |
107 | - $tab = ( isset ( $_GET['tab'] ) ? $_GET['tab'] : $default ); |
|
107 | + $tab = ( isset ( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : $default ); |
|
108 | 108 | |
109 | 109 | // If the pod settings aren't configured yet, open the 'Setup' tab. |
110 | 110 | if ( ! $this->is_pod_set_up() ) { |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | // The array defining all options sections to be shown as tabs. |
125 | 125 | $tabs = array(); |
126 | 126 | if ( $this->is_pod_set_up() ) { |
127 | - $tabs['defaults'] = __( 'Defaults', 'wp-to-diaspora' ); |
|
127 | + $tabs[ 'defaults' ] = __( 'Defaults', 'wp-to-diaspora' ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | // Add the 'Setup' tab to the end of the list. |
131 | - $tabs['setup'] = __( 'Setup', 'wp-to-diaspora' ) . '<span id="pod-connection-status" class="dashicons-before hidden"></span><span class="spinner"></span>'; |
|
131 | + $tabs[ 'setup' ] = __( 'Setup', 'wp-to-diaspora' ) . '<span id="pod-connection-status" class="dashicons-before hidden"></span><span class="spinner"></span>'; |
|
132 | 132 | |
133 | 133 | // Container for all options tabs. |
134 | 134 | $out = '<h2 id="options-tabs" class="nav-tab-wrapper">'; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | do_settings_sections( 'wp_to_diaspora_settings' ); |
221 | 221 | |
222 | 222 | // Get the name of the current tab, if set, else take the first one from the list. |
223 | - $tab = $this->_current_tab( $page_tabs[0] ); |
|
223 | + $tab = $this->_current_tab( $page_tabs[ 0 ] ); |
|
224 | 224 | |
225 | 225 | // Add Save and Reset buttons. |
226 | 226 | echo '<input id="submit-' . esc_attr( $tab ) . '" name="wp_to_diaspora_settings[submit_' . esc_attr( $tab ) . ']" type="submit" class="button-primary" value="' . esc_attr__( 'Save Changes' ) . '" /> '; |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | <select id="tags-to-post" multiple data-placeholder="<?php esc_attr_e( 'No tags', 'wp-to-diaspora' ); ?>" class="chosen" name="wp_to_diaspora_settings[tags_to_post][]"> |
599 | 599 | <option value="global" <?php selected( in_array( 'global', $tags_to_post ) ); ?>><?php esc_html_e( 'Global tags', 'wp-to-diaspora' ); ?></option> |
600 | 600 | <option value="custom" <?php selected( in_array( 'custom', $tags_to_post ) ); ?>><?php esc_html_e( 'Custom tags', 'wp-to-diaspora' ); ?></option> |
601 | - <option value="post" <?php selected( in_array( 'post', $tags_to_post ) ); ?>><?php esc_html_e( 'Post tags', 'wp-to-diaspora' ); ?></option> |
|
601 | + <option value="post" <?php selected( in_array( 'post', $tags_to_post ) ); ?>><?php esc_html_e( 'Post tags', 'wp-to-diaspora' ); ?></option> |
|
602 | 602 | </select> |
603 | 603 | |
604 | 604 | <?php if ( $on_settings_page ) : ?> |
@@ -664,14 +664,14 @@ discard block |
||
664 | 664 | esc_url( 'https://' . $this->get_option( 'pod' ) . '/services' ), |
665 | 665 | esc_html__( 'Show available services on my pod.', 'wp-to-diaspora' ) |
666 | 666 | ); |
667 | - $empty_label = esc_html__( 'No services connected yet.', 'wp-to-diaspora' ); |
|
667 | + $empty_label = esc_html__( 'No services connected yet.', 'wp-to-diaspora' ); |
|
668 | 668 | break; |
669 | 669 | |
670 | 670 | default: |
671 | 671 | return; |
672 | 672 | } |
673 | 673 | |
674 | - $items = array_filter( (array) $items ) ?: array(); |
|
674 | + $items = array_filter( (array) $items ) ? : array(); |
|
675 | 675 | |
676 | 676 | // Special case for this field if it's displayed on the settings page. |
677 | 677 | $on_settings_page = ( 'settings_page_wp_to_diaspora' === get_current_screen()->id ); |
@@ -798,30 +798,30 @@ discard block |
||
798 | 798 | /* Validate all settings before saving to the database. */ |
799 | 799 | |
800 | 800 | // Saving the pod setup details. |
801 | - if ( isset( $input['submit_setup'] ) ) { |
|
802 | - $input['pod'] = trim( sanitize_text_field( $input['pod'] ), ' /' ); |
|
803 | - $input['username'] = sanitize_text_field( $input['username'] ); |
|
804 | - $input['password'] = sanitize_text_field( $input['password'] ); |
|
801 | + if ( isset( $input[ 'submit_setup' ] ) ) { |
|
802 | + $input[ 'pod' ] = trim( sanitize_text_field( $input[ 'pod' ] ), ' /' ); |
|
803 | + $input[ 'username' ] = sanitize_text_field( $input[ 'username' ] ); |
|
804 | + $input[ 'password' ] = sanitize_text_field( $input[ 'password' ] ); |
|
805 | 805 | |
806 | 806 | // If password is blank, it hasn't been changed. |
807 | 807 | // If new password is equal to the encrypted password already saved, it was just passed again. It happens everytime update_option('wp_to_diaspora_settings') is called. |
808 | - if ( '' === $input['password'] || $this->get_option( 'password' ) === $input['password'] ) { |
|
809 | - $input['password'] = $this->get_option( 'password' ); |
|
808 | + if ( '' === $input[ 'password' ] || $this->get_option( 'password' ) === $input[ 'password' ] ) { |
|
809 | + $input[ 'password' ] = $this->get_option( 'password' ); |
|
810 | 810 | } else { |
811 | - $input['password'] = WP2D_Helpers::encrypt( $input['password'] ); |
|
811 | + $input[ 'password' ] = WP2D_Helpers::encrypt( $input[ 'password' ] ); |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | // This is for when JS in not enabled, to make sure that the aspects and services |
815 | 815 | // are refetched when displaying the options page after saving. |
816 | - if ( isset( $input['no_js'] ) ) { |
|
816 | + if ( isset( $input[ 'no_js' ] ) ) { |
|
817 | 817 | set_transient( 'wp2d_no_js_force_refetch', true ); |
818 | 818 | } |
819 | 819 | } |
820 | 820 | |
821 | 821 | // Saving the default options. |
822 | - if ( isset( $input['submit_defaults'] ) ) { |
|
823 | - if ( ! isset( $input['enabled_post_types'] ) ) { |
|
824 | - $input['enabled_post_types'] = array(); |
|
822 | + if ( isset( $input[ 'submit_defaults' ] ) ) { |
|
823 | + if ( ! isset( $input[ 'enabled_post_types' ] ) ) { |
|
824 | + $input[ 'enabled_post_types' ] = array(); |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | // Checkboxes. |
@@ -834,29 +834,29 @@ discard block |
||
834 | 834 | $this->validate_multi_selects( 'tags_to_post', $input ); |
835 | 835 | |
836 | 836 | // Get unique, non-empty, trimmed tags and clean them up. |
837 | - $this->validate_tags( $input['global_tags'] ); |
|
837 | + $this->validate_tags( $input[ 'global_tags' ] ); |
|
838 | 838 | |
839 | 839 | // Clean up the list of aspects. If the list is empty, only use the 'Public' aspect. |
840 | - $this->validate_aspects_services( $input['aspects'], array( 'public' ) ); |
|
840 | + $this->validate_aspects_services( $input[ 'aspects' ], array( 'public' ) ); |
|
841 | 841 | |
842 | 842 | // Clean up the list of services. |
843 | - $this->validate_aspects_services( $input['services'] ); |
|
843 | + $this->validate_aspects_services( $input[ 'services' ] ); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | // Reset to defaults. |
847 | - if ( isset( $input['reset_defaults'] ) ) { |
|
847 | + if ( isset( $input[ 'reset_defaults' ] ) ) { |
|
848 | 848 | // Set the input to the default options. |
849 | 849 | $input = self::$_default_options; |
850 | 850 | |
851 | 851 | // Don't reset the fetched lists of aspects and services. |
852 | - unset( $input['aspects_list'] ); |
|
853 | - unset( $input['services_list'] ); |
|
852 | + unset( $input[ 'aspects_list' ] ); |
|
853 | + unset( $input[ 'services_list' ] ); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | // Unset all unused input fields. |
857 | - unset( $input['submit_defaults'] ); |
|
858 | - unset( $input['reset_defaults'] ); |
|
859 | - unset( $input['submit_setup'] ); |
|
857 | + unset( $input[ 'submit_defaults' ] ); |
|
858 | + unset( $input[ 'reset_defaults' ] ); |
|
859 | + unset( $input[ 'submit_setup' ] ); |
|
860 | 860 | |
861 | 861 | // Parse inputs with default options and return. |
862 | 862 | return wp_parse_args( $input, array_merge( self::$_default_options, self::$_options ) ); |
@@ -191,7 +191,7 @@ |
||
191 | 191 | * |
192 | 192 | * @param integer $post_id ID of the post being saved. |
193 | 193 | * @param WP_Post $post Post object being saved. |
194 | - * @return boolean If the post was posted successfully. |
|
194 | + * @return false|null If the post was posted successfully. |
|
195 | 195 | */ |
196 | 196 | public function post( $post_id, $post ) { |
197 | 197 | $this->_assign_wp_post( $post ); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | |
251 | 251 | // Unset post_to_diaspora meta field to prevent mistakenly republishing to diaspora*. |
252 | 252 | $meta = get_post_meta( $post_id, '_wp_to_diaspora', true ); |
253 | - $meta['post_to_diaspora'] = false; |
|
253 | + $meta[ 'post_to_diaspora' ] = false; |
|
254 | 254 | update_post_meta( $post_id, '_wp_to_diaspora', $meta ); |
255 | 255 | } |
256 | 256 | } else { |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | // Get all the tags and list them all nicely in a row. |
394 | 394 | $diaspora_tags_clean = array(); |
395 | 395 | foreach ( $diaspora_tags as $tag ) { |
396 | - $diaspora_tags_clean[] = '#' . $tag; |
|
396 | + $diaspora_tags_clean[ ] = '#' . $tag; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | // Add all the found tags. |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | } |
454 | 454 | |
455 | 455 | // Add a new entry to the history. |
456 | - $this->post_history[] = array( |
|
456 | + $this->post_history[ ] = array( |
|
457 | 457 | 'id' => $response->id, |
458 | 458 | 'guid' => $response->guid, |
459 | 459 | 'created_at' => $this->post->post_modified, |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | return ''; |
508 | 508 | } |
509 | 509 | |
510 | - $default = sprintf( '<blockquote>%s</blockquote>', $caption ); |
|
510 | + $default = sprintf( '<blockquote>%s</blockquote>', $caption ); |
|
511 | 511 | |
512 | 512 | /** |
513 | 513 | * Filter the image caption to be displayed after images with captions. |
@@ -535,8 +535,8 @@ discard block |
||
535 | 535 | $content = do_shortcode( $content ); |
536 | 536 | |
537 | 537 | // If a caption attribute is defined, we'll add it after the image. |
538 | - if ( isset( $attr['caption'] ) && '' !== $attr['caption'] ) { |
|
539 | - $content .= "\n" . $this->get_img_caption( $attr['caption'] ); |
|
538 | + if ( isset( $attr[ 'caption' ] ) && '' !== $attr[ 'caption' ] ) { |
|
539 | + $content .= "\n" . $this->get_img_caption( $attr[ 'caption' ] ); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | return $content; |
@@ -555,8 +555,8 @@ discard block |
||
555 | 555 | $captiontag = ( current_theme_supports( 'html5', 'gallery' ) ) ? 'figcaption' : 'dd'; |
556 | 556 | |
557 | 557 | // User value. |
558 | - if ( isset( $attr['captiontag'] ) ) { |
|
559 | - $captiontag = $attr['captiontag']; |
|
558 | + if ( isset( $attr[ 'captiontag' ] ) ) { |
|
559 | + $captiontag = $attr[ 'captiontag' ]; |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | // Let WordPress create the regular gallery. |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | * @return string Prettified gallery image caption. |
580 | 580 | */ |
581 | 581 | public function custom_gallery_regex_callback( $m ) { |
582 | - return $this->get_img_caption( $m[2] ); |
|
582 | + return $this->get_img_caption( $m[ 2 ] ); |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | /* |
@@ -622,18 +622,18 @@ discard block |
||
622 | 622 | $options = WP2D_Options::instance(); |
623 | 623 | |
624 | 624 | // Make sure we have some value for post meta fields. |
625 | - $this->custom_tags = $this->custom_tags ?: array(); |
|
625 | + $this->custom_tags = $this->custom_tags ? : array(); |
|
626 | 626 | |
627 | 627 | // If this post is already published, don't post again to diaspora* by default. |
628 | 628 | $this->post_to_diaspora = ( $this->post_to_diaspora && 'publish' !== get_post_status( $this->ID ) ); |
629 | - $this->aspects = $this->aspects ?: array(); |
|
630 | - $this->services = $this->services ?: array(); |
|
629 | + $this->aspects = $this->aspects ? : array(); |
|
630 | + $this->services = $this->services ? : array(); |
|
631 | 631 | |
632 | 632 | // Have we already posted on diaspora*? |
633 | 633 | if ( is_array( $this->post_history ) ) { |
634 | 634 | $latest_post = end( $this->post_history ); |
635 | 635 | ?> |
636 | - <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> |
|
636 | + <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> |
|
637 | 637 | <?php |
638 | 638 | } |
639 | 639 | ?> |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | /* OK, it's safe for us to save the data now. */ |
669 | 669 | |
670 | 670 | // Meta data to save. |
671 | - $meta_to_save = $_POST['wp_to_diaspora_settings']; |
|
671 | + $meta_to_save = $_POST[ 'wp_to_diaspora_settings' ]; |
|
672 | 672 | $options = WP2D_Options::instance(); |
673 | 673 | |
674 | 674 | // Checkboxes. |
@@ -681,13 +681,13 @@ discard block |
||
681 | 681 | $options->validate_multi_selects( 'tags_to_post', $meta_to_save ); |
682 | 682 | |
683 | 683 | // Save custom tags as array. |
684 | - $options->validate_tags( $meta_to_save['custom_tags'] ); |
|
684 | + $options->validate_tags( $meta_to_save[ 'custom_tags' ] ); |
|
685 | 685 | |
686 | 686 | // Clean up the list of aspects. If the list is empty, only use the 'Public' aspect. |
687 | - $options->validate_aspects_services( $meta_to_save['aspects'], array( 'public' ) ); |
|
687 | + $options->validate_aspects_services( $meta_to_save[ 'aspects' ], array( 'public' ) ); |
|
688 | 688 | |
689 | 689 | // Clean up the list of services. |
690 | - $options->validate_aspects_services( $meta_to_save['services'] ); |
|
690 | + $options->validate_aspects_services( $meta_to_save[ 'services' ] ); |
|
691 | 691 | |
692 | 692 | // Update the meta data for this post. |
693 | 693 | update_post_meta( $post_id, '_wp_to_diaspora', $meta_to_save ); |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | */ |
703 | 703 | private function _is_safe_to_save() { |
704 | 704 | // Verify that our nonce is set and valid. |
705 | - if ( ! ( isset( $_POST['wp_to_diaspora_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wp_to_diaspora_meta_box_nonce'], 'wp_to_diaspora_meta_box' ) ) ) { |
|
705 | + if ( ! ( isset( $_POST[ 'wp_to_diaspora_meta_box_nonce' ] ) && wp_verify_nonce( $_POST[ 'wp_to_diaspora_meta_box_nonce' ], 'wp_to_diaspora_meta_box' ) ) ) { |
|
706 | 706 | return false; |
707 | 707 | } |
708 | 708 | |
@@ -712,13 +712,13 @@ discard block |
||
712 | 712 | } |
713 | 713 | |
714 | 714 | // Check the user's permissions. |
715 | - $permission = ( isset( $_POST['post_type'] ) && 'page' === $_POST['post_type'] ) ? 'edit_pages' : 'edit_posts'; |
|
715 | + $permission = ( isset( $_POST[ 'post_type' ] ) && 'page' === $_POST[ 'post_type' ] ) ? 'edit_pages' : 'edit_posts'; |
|
716 | 716 | if ( ! current_user_can( $permission, $this->ID ) ) { |
717 | 717 | return false; |
718 | 718 | } |
719 | 719 | |
720 | 720 | // Make real sure that we have some meta data to save. |
721 | - if ( ! isset( $_POST['wp_to_diaspora_settings'] ) ) { |
|
721 | + if ( ! isset( $_POST[ 'wp_to_diaspora_settings' ] ) ) { |
|
722 | 722 | return false; |
723 | 723 | } |
724 | 724 | |
@@ -755,10 +755,10 @@ discard block |
||
755 | 755 | $latest_post = end( $diaspora_post_history ); |
756 | 756 | |
757 | 757 | // Only show if this post is showing a message and the post is a fresh share. |
758 | - if ( isset( $_GET['message'] ) && $post->post_modified === $latest_post['created_at'] ) { |
|
758 | + if ( isset( $_GET[ 'message' ] ) && $post->post_modified === $latest_post[ 'created_at' ] ) { |
|
759 | 759 | printf( '<div class="updated notice is-dismissible"><p>%1$s <a href="%2$s" target="_blank">%3$s</a></p></div>', |
760 | 760 | esc_html__( 'Successfully posted to diaspora*.', 'wp-to-diaspora' ), |
761 | - esc_url( $latest_post['post_url'] ), |
|
761 | + esc_url( $latest_post[ 'post_url' ] ), |
|
762 | 762 | esc_html__( 'View Post' ) |
763 | 763 | ); |
764 | 764 | } |
@@ -772,8 +772,8 @@ discard block |
||
772 | 772 | */ |
773 | 773 | public function ignore_post_error() { |
774 | 774 | // If "Ignore" link has been clicked, delete the post error meta data. |
775 | - if ( isset( $_GET['wp2d_ignore_post_error'], $_GET['post'] ) ) { |
|
776 | - delete_post_meta( $_GET['post'], '_wp_to_diaspora_post_error' ); |
|
775 | + if ( isset( $_GET[ 'wp2d_ignore_post_error' ], $_GET[ 'post' ] ) ) { |
|
776 | + delete_post_meta( $_GET[ 'post' ], '_wp_to_diaspora_post_error' ); |
|
777 | 777 | } |
778 | 778 | } |
779 | 779 | } |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * Add the "Settings" link to the plugins page. |
288 | 288 | * |
289 | 289 | * @param array $links Links to display for plugin on plugins page. |
290 | - * @return array Links to display for plugin on plugins page. |
|
290 | + * @return string[] Links to display for plugin on plugins page. |
|
291 | 291 | */ |
292 | 292 | public function settings_link( $links ) { |
293 | 293 | $links[] = '<a href="' . admin_url( 'options-general.php?page=wp_to_diaspora' ) . '">' . __( 'Settings' ) . '</a>'; |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | /** |
401 | 401 | * Check the pod connection status. |
402 | 402 | * |
403 | - * @return string The status of the connection. |
|
403 | + * @return boolean|null The status of the connection. |
|
404 | 404 | */ |
405 | 405 | private function _check_pod_connection_status() { |
406 | 406 | $options = WP2D_Options::instance(); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | private function _constants() { |
101 | 101 | // Are we in debugging mode? |
102 | - if ( isset( $_GET['debugging'] ) ) { |
|
102 | + if ( isset( $_GET[ 'debugging' ] ) ) { |
|
103 | 103 | define( 'WP2D_DEBUGGING', true ); |
104 | 104 | } |
105 | 105 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | private function _version_check() { |
119 | 119 | // Check for version requirements. |
120 | - if ( version_compare( $GLOBALS['wp_version'], $this->_min_wp, '<' ) |
|
120 | + if ( version_compare( $GLOBALS[ 'wp_version' ], $this->_min_wp, '<' ) |
|
121 | 121 | || version_compare( PHP_VERSION, $this->_min_php, '<' ) ) { |
122 | 122 | add_action( 'admin_notices', array( $this, 'deactivate' ) ); |
123 | 123 | return false; |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | deactivate_plugins( plugin_basename( __FILE__ ) ); |
137 | 137 | |
138 | 138 | // Get rid of the "Plugin activated" message. |
139 | - unset( $_GET['activate'] ); |
|
139 | + unset( $_GET[ 'activate' ] ); |
|
140 | 140 | |
141 | 141 | // Then display the admin notice. |
142 | 142 | ?> |
143 | 143 | <div class="error"> |
144 | - <p><?php echo esc_html( sprintf( 'WP to diaspora* requires at least WordPress %1$s (you have %2$s) and PHP %3$s (you have %4$s)!', $this->_min_wp, $GLOBALS['wp_version'], $this->_min_php, PHP_VERSION ) ); ?></p> |
|
144 | + <p><?php echo esc_html( sprintf( 'WP to diaspora* requires at least WordPress %1$s (you have %2$s) and PHP %3$s (you have %4$s)!', $this->_min_wp, $GLOBALS[ 'wp_version' ], $this->_min_php, PHP_VERSION ) ); ?></p> |
|
145 | 145 | </div> |
146 | 146 | <?php |
147 | 147 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $tags_to_post = array_filter( array( |
237 | 237 | ( ( false !== strpos( $tags_to_post_old, 'g' ) ) ? 'global' : null ), |
238 | 238 | ( ( false !== strpos( $tags_to_post_old, 'c' ) ) ? 'custom' : null ), |
239 | - ( ( false !== strpos( $tags_to_post_old, 'p' ) ) ? 'post' : null ), |
|
239 | + ( ( false !== strpos( $tags_to_post_old, 'p' ) ) ? 'post' : null ), |
|
240 | 240 | ) ); |
241 | 241 | $options->set_option( 'tags_to_post', $tags_to_post ); |
242 | 242 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @return array Links to display for plugin on plugins page. |
291 | 291 | */ |
292 | 292 | public function settings_link( $links ) { |
293 | - $links[] = '<a href="' . admin_url( 'options-general.php?page=wp_to_diaspora' ) . '">' . __( 'Settings' ) . '</a>'; |
|
293 | + $links[ ] = '<a href="' . admin_url( 'options-general.php?page=wp_to_diaspora' ) . '">' . __( 'Settings' ) . '</a>'; |
|
294 | 294 | return $links; |
295 | 295 | } |
296 | 296 | |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @todo esc_html |
379 | 379 | */ |
380 | 380 | public function check_pod_connection_status_callback() { |
381 | - if ( isset( $_REQUEST['debugging'] ) && ! defined( 'WP2D_DEBUGGING' ) ) { |
|
381 | + if ( isset( $_REQUEST[ 'debugging' ] ) && ! defined( 'WP2D_DEBUGGING' ) ) { |
|
382 | 382 | define( 'WP2D_DEBUGGING', true ); |
383 | 383 | } |
384 | 384 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | if ( true === $status ) { |
393 | 393 | wp_send_json_success( $data ); |
394 | 394 | } elseif ( false === $status && $this->_load_api()->has_last_error() ) { |
395 | - $data['message'] = $this->_load_api()->get_last_error() . ' ' . WP2D_Contextual_Help::get_help_tab_quick_link( $this->_load_api()->get_last_error_object() ); |
|
395 | + $data[ 'message' ] = $this->_load_api()->get_last_error() . ' ' . WP2D_Contextual_Help::get_help_tab_quick_link( $this->_load_api()->get_last_error_object() ); |
|
396 | 396 | wp_send_json_error( $data ); |
397 | 397 | } |
398 | 398 | // If $status === null, do nothing. |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | * @since 1.5.0 |
42 | 42 | */ |
43 | 43 | private function _constants() { |
44 | - define( 'WP2D_EXT_WPORG', esc_url( 'https://wordpress.org/plugins/wp-to-diaspora' ) ); |
|
45 | - define( 'WP2D_EXT_I18N', esc_url( 'https://poeditor.com/join/project?hash=c085b3654a5e04c69ec942e0f136716a' ) ); |
|
46 | - define( 'WP2D_EXT_GH', esc_url( 'https://github.com/DiasPHPora/wp-to-diaspora' ) ); |
|
47 | - define( 'WP2D_EXT_DONATE', esc_url( 'https://github.com/DiasPHPora/wp-to-diaspora#donate' ) ); |
|
48 | - define( 'WP2D_EXT_GH_ISSUES', esc_url( 'https://github.com/DiasPHPora/wp-to-diaspora/issues' ) ); |
|
44 | + define( 'WP2D_EXT_WPORG', esc_url( 'https://wordpress.org/plugins/wp-to-diaspora' ) ); |
|
45 | + define( 'WP2D_EXT_I18N', esc_url( 'https://poeditor.com/join/project?hash=c085b3654a5e04c69ec942e0f136716a' ) ); |
|
46 | + define( 'WP2D_EXT_GH', esc_url( 'https://github.com/DiasPHPora/wp-to-diaspora' ) ); |
|
47 | + define( 'WP2D_EXT_DONATE', esc_url( 'https://github.com/DiasPHPora/wp-to-diaspora#donate' ) ); |
|
48 | + define( 'WP2D_EXT_GH_ISSUES', esc_url( 'https://github.com/DiasPHPora/wp-to-diaspora/issues' ) ); |
|
49 | 49 | define( 'WP2D_EXT_GH_ISSUES_NEW', esc_url( 'https://github.com/DiasPHPora/wp-to-diaspora/issues/new' ) ); |
50 | 50 | } |
51 | 51 | |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | get_current_screen()->set_help_sidebar( |
90 | 90 | '<p><strong>' . esc_html__( 'WP to diaspora*', 'wp-to-diaspora' ) . '</strong></p> |
91 | 91 | <ul> |
92 | - <li><a href="' . WP2D_EXT_GH . '" target="_blank">GitHub</a> |
|
93 | - <li><a href="' . WP2D_EXT_WPORG . '" target="_blank">WordPress.org</a> |
|
94 | - <li><a href="' . WP2D_EXT_I18N . '" target="_blank">' . esc_html__( 'Help with translations', 'wp-to-diaspora' ) . '</a> |
|
95 | - <li><a href="' . WP2D_EXT_DONATE . '" target="_blank">' . esc_html__( 'Make a donation', 'wp-to-diaspora' ) . '</a> |
|
92 | + <li><a href="' . WP2D_EXT_GH . '" target="_blank">GitHub</a> |
|
93 | + <li><a href="' . WP2D_EXT_WPORG . '" target="_blank">WordPress.org</a> |
|
94 | + <li><a href="' . WP2D_EXT_I18N . '" target="_blank">' . esc_html__( 'Help with translations', 'wp-to-diaspora' ) . '</a> |
|
95 | + <li><a href="' . WP2D_EXT_DONATE . '" target="_blank">' . esc_html__( 'Make a donation', 'wp-to-diaspora' ) . '</a> |
|
96 | 96 | </ul>' |
97 | 97 | ); |
98 | 98 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | <ul> |
151 | 151 | <li><strong>' . esc_html__( 'Global tags', 'wp-to-diaspora' ) . '</strong>: ' . esc_html__( 'Tags that apply to all posts.', 'wp-to-diaspora' ) . ' |
152 | 152 | <li><strong>' . esc_html__( 'Custom tags', 'wp-to-diaspora' ) . '</strong>: ' . esc_html__( 'Tags that apply to individual posts (can be set on each post).', 'wp-to-diaspora' ) . ' |
153 | - <li><strong>' . esc_html__( 'Post tags', 'wp-to-diaspora' ) . '</strong>: ' . esc_html__( 'Default WordPress Tags of individual posts.', 'wp-to-diaspora' ) . ' |
|
153 | + <li><strong>' . esc_html__( 'Post tags', 'wp-to-diaspora' ) . '</strong>: ' . esc_html__( 'Default WordPress Tags of individual posts.', 'wp-to-diaspora' ) . ' |
|
154 | 154 | </ul> |
155 | 155 | <li><strong>' . esc_html__( 'Global tags', 'wp-to-diaspora' ) . '</strong>: ' . |
156 | 156 | esc_html__( 'A list of tags that gets added to every post.', 'wp-to-diaspora' ) . ' |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | 'content' => '<p><strong>' . esc_html__( 'So you feel like contributing to the WP to diaspora* plugin? Great!', 'wp-to-diaspora' ) . '</strong></p> |
218 | 218 | <p>' . esc_html__( 'There are many different ways that you can help out with this plugin:', 'wp-to-diaspora' ) . '</p> |
219 | 219 | <ul> |
220 | - <li><a href="' . WP2D_EXT_GH_ISSUES_NEW . '" target="_blank">' . esc_html__( 'Report a bug', 'wp-to-diaspora' ) . '</a> |
|
221 | - <li><a href="' . WP2D_EXT_GH_ISSUES_NEW . '" target="_blank">' . esc_html__( 'Suggest a new feature', 'wp-to-diaspora' ) . '</a> |
|
222 | - <li><a href="' . WP2D_EXT_I18N . '" target="_blank">' . esc_html__( 'Help with translations', 'wp-to-diaspora' ) . '</a> |
|
223 | - <li><a href="' . WP2D_EXT_DONATE . '" target="_blank">' . esc_html__( 'Make a donation', 'wp-to-diaspora' ) . '</a> |
|
220 | + <li><a href="' . WP2D_EXT_GH_ISSUES_NEW . '" target="_blank">' . esc_html__( 'Report a bug', 'wp-to-diaspora' ) . '</a> |
|
221 | + <li><a href="' . WP2D_EXT_GH_ISSUES_NEW . '" target="_blank">' . esc_html__( 'Suggest a new feature', 'wp-to-diaspora' ) . '</a> |
|
222 | + <li><a href="' . WP2D_EXT_I18N . '" target="_blank">' . esc_html__( 'Help with translations', 'wp-to-diaspora' ) . '</a> |
|
223 | + <li><a href="' . WP2D_EXT_DONATE . '" target="_blank">' . esc_html__( 'Make a donation', 'wp-to-diaspora' ) . '</a> |
|
224 | 224 | </ul>', |
225 | 225 | ) ); |
226 | 226 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | public static function get_help_tab_quick_link( $error ) { |
251 | 251 | $help_tab = ''; |
252 | 252 | if ( is_wp_error( $error ) && ( $error_data = $error->get_error_data() ) && array_key_exists( 'help_tab', $error_data ) ) { |
253 | - $help_tab = $error_data['help_tab']; |
|
253 | + $help_tab = $error_data[ 'help_tab' ]; |
|
254 | 254 | } elseif ( is_string( $error ) ) { |
255 | 255 | $help_tab = $error; |
256 | 256 | } |