@@ -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() ) { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @return string Return the currently selected tab. |
| 106 | 106 | */ |
| 107 | 107 | private function _current_tab( $default = 'defaults' ) { |
| 108 | - $tab = ( isset ( $_GET['tab'] ) ? $_GET['tab'] : $default ); |
|
| 108 | + $tab = ( isset ( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : $default ); |
|
| 109 | 109 | |
| 110 | 110 | // If the pod settings aren't configured yet, open the 'Setup' tab. |
| 111 | 111 | if ( ! $this->is_pod_set_up() ) { |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | // The array defining all options sections to be shown as tabs. |
| 126 | 126 | $tabs = array(); |
| 127 | 127 | if ( $this->is_pod_set_up() ) { |
| 128 | - $tabs['defaults'] = __( 'Defaults', 'wp-to-diaspora' ); |
|
| 128 | + $tabs[ 'defaults' ] = __( 'Defaults', 'wp-to-diaspora' ); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // Add the 'Setup' tab to the end of the list. |
| 132 | - $tabs['setup'] = __( 'Setup', 'wp-to-diaspora' ) . '<span id="pod-connection-status" class="dashicons-before hidden"></span><span class="spinner"></span>'; |
|
| 132 | + $tabs[ 'setup' ] = __( 'Setup', 'wp-to-diaspora' ) . '<span id="pod-connection-status" class="dashicons-before hidden"></span><span class="spinner"></span>'; |
|
| 133 | 133 | |
| 134 | 134 | // Container for all options tabs. |
| 135 | 135 | $out = '<h2 id="options-tabs" class="nav-tab-wrapper">'; |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | // Attempt to get the cacert.pem file and save it to the plugin's root directory. |
| 210 | - if ( isset( $_GET['wp2d_temp_ssl_fix'] ) ) { |
|
| 210 | + if ( isset( $_GET[ 'wp2d_temp_ssl_fix' ] ) ) { |
|
| 211 | 211 | $cacert_file = file_get_contents( 'http://curl.haxx.se/ca/cacert.pem' ); |
| 212 | 212 | if ( $cacert_file && file_put_contents( WP2D_DIR . '/cacert.pem', $cacert_file ) ) { |
| 213 | 213 | add_settings_error( |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | do_settings_sections( 'wp_to_diaspora_settings' ); |
| 242 | 242 | |
| 243 | 243 | // Get the name of the current tab, if set, else take the first one from the list. |
| 244 | - $tab = $this->_current_tab( $page_tabs[0] ); |
|
| 244 | + $tab = $this->_current_tab( $page_tabs[ 0 ] ); |
|
| 245 | 245 | |
| 246 | 246 | // Add Save and Reset buttons. |
| 247 | 247 | 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' ) . '" /> '; |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | https://<input type="text" name="wp_to_diaspora_settings[pod]" value="<?php echo esc_attr( $this->get_option( 'pod' ) ); ?>" placeholder="e.g. joindiaspora.com" autocomplete="on" list="pod-list" required> <a id="refresh-pod-list" class="button hide-if-no-js"><?php esc_html_e( 'Refresh pod list', 'wp-to-diaspora' ); ?></a><span class="spinner"></span> |
| 326 | 326 | <datalist id="pod-list"> |
| 327 | 327 | <?php foreach ( (array) $this->get_option( 'pod_list' ) as $pod ) : ?> |
| 328 | - <option data-secure="<?php echo esc_attr( $pod['secure'] ); ?>" value="<?php echo esc_attr( $pod['domain'] ); ?>"></option> |
|
| 328 | + <option data-secure="<?php echo esc_attr( $pod[ 'secure' ] ); ?>" value="<?php echo esc_attr( $pod[ 'domain' ] ); ?>"></option> |
|
| 329 | 329 | <?php endforeach; ?> |
| 330 | 330 | </datalist> |
| 331 | 331 | <?php |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | <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][]"> |
| 470 | 470 | <option value="global" <?php selected( in_array( 'global', $tags_to_post ) ); ?>><?php esc_html_e( 'Global tags', 'wp-to-diaspora' ); ?></option> |
| 471 | 471 | <option value="custom" <?php selected( in_array( 'custom', $tags_to_post ) ); ?>><?php esc_html_e( 'Custom tags', 'wp-to-diaspora' ); ?></option> |
| 472 | - <option value="post" <?php selected( in_array( 'post', $tags_to_post ) ); ?>><?php esc_html_e( 'Post tags', 'wp-to-diaspora' ); ?></option> |
|
| 472 | + <option value="post" <?php selected( in_array( 'post', $tags_to_post ) ); ?>><?php esc_html_e( 'Post tags', 'wp-to-diaspora' ); ?></option> |
|
| 473 | 473 | </select> |
| 474 | 474 | |
| 475 | 475 | <?php if ( $on_settings_page ) : ?> |
@@ -535,14 +535,14 @@ discard block |
||
| 535 | 535 | esc_url( 'https://' . $this->get_option( 'pod' ) . '/services' ), |
| 536 | 536 | esc_html__( 'Show available services on my pod.', 'wp-to-diaspora' ) |
| 537 | 537 | ); |
| 538 | - $empty_label = esc_html__( 'No services connected yet.', 'wp-to-diaspora' ); |
|
| 538 | + $empty_label = esc_html__( 'No services connected yet.', 'wp-to-diaspora' ); |
|
| 539 | 539 | break; |
| 540 | 540 | |
| 541 | 541 | default: |
| 542 | 542 | return; |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | - $items = array_filter( (array) $items ) ?: array(); |
|
| 545 | + $items = array_filter( (array) $items ) ? : array(); |
|
| 546 | 546 | |
| 547 | 547 | // Special case for this field if it's displayed on the settings page. |
| 548 | 548 | $on_settings_page = ( 'settings_page_wp_to_diaspora' === get_current_screen()->id ); |
@@ -669,30 +669,30 @@ discard block |
||
| 669 | 669 | /* Validate all settings before saving to the database. */ |
| 670 | 670 | |
| 671 | 671 | // Saving the pod setup details. |
| 672 | - if ( isset( $input['submit_setup'] ) ) { |
|
| 673 | - $input['pod'] = trim( sanitize_text_field( $input['pod'] ), ' /' ); |
|
| 674 | - $input['username'] = sanitize_text_field( $input['username'] ); |
|
| 675 | - $input['password'] = sanitize_text_field( $input['password'] ); |
|
| 672 | + if ( isset( $input[ 'submit_setup' ] ) ) { |
|
| 673 | + $input[ 'pod' ] = trim( sanitize_text_field( $input[ 'pod' ] ), ' /' ); |
|
| 674 | + $input[ 'username' ] = sanitize_text_field( $input[ 'username' ] ); |
|
| 675 | + $input[ 'password' ] = sanitize_text_field( $input[ 'password' ] ); |
|
| 676 | 676 | |
| 677 | 677 | // If password is blank, it hasn't been changed. |
| 678 | 678 | // 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. |
| 679 | - if ( '' === $input['password'] || $this->get_option( 'password' ) === $input['password'] ) { |
|
| 680 | - $input['password'] = $this->get_option( 'password' ); |
|
| 679 | + if ( '' === $input[ 'password' ] || $this->get_option( 'password' ) === $input[ 'password' ] ) { |
|
| 680 | + $input[ 'password' ] = $this->get_option( 'password' ); |
|
| 681 | 681 | } else { |
| 682 | - $input['password'] = WP2D_Helpers::encrypt( $input['password'] ); |
|
| 682 | + $input[ 'password' ] = WP2D_Helpers::encrypt( $input[ 'password' ] ); |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | // This is for when JS in not enabled, to make sure that the aspects and services |
| 686 | 686 | // are refetched when displaying the options page after saving. |
| 687 | - if ( isset( $input['no_js'] ) ) { |
|
| 687 | + if ( isset( $input[ 'no_js' ] ) ) { |
|
| 688 | 688 | set_transient( 'wp2d_no_js_force_refetch', true ); |
| 689 | 689 | } |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | // Saving the default options. |
| 693 | - if ( isset( $input['submit_defaults'] ) ) { |
|
| 694 | - if ( ! isset( $input['enabled_post_types'] ) ) { |
|
| 695 | - $input['enabled_post_types'] = array(); |
|
| 693 | + if ( isset( $input[ 'submit_defaults' ] ) ) { |
|
| 694 | + if ( ! isset( $input[ 'enabled_post_types' ] ) ) { |
|
| 695 | + $input[ 'enabled_post_types' ] = array(); |
|
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | // Checkboxes. |
@@ -705,30 +705,30 @@ discard block |
||
| 705 | 705 | $this->validate_multi_selects( 'tags_to_post', $input ); |
| 706 | 706 | |
| 707 | 707 | // Get unique, non-empty, trimmed tags and clean them up. |
| 708 | - $this->validate_tags( $input['global_tags'] ); |
|
| 708 | + $this->validate_tags( $input[ 'global_tags' ] ); |
|
| 709 | 709 | |
| 710 | 710 | // Clean up the list of aspects. If the list is empty, only use the 'Public' aspect. |
| 711 | - $this->validate_aspects_services( $input['aspects'], array( 'public' ) ); |
|
| 711 | + $this->validate_aspects_services( $input[ 'aspects' ], array( 'public' ) ); |
|
| 712 | 712 | |
| 713 | 713 | // Clean up the list of services. |
| 714 | - $this->validate_aspects_services( $input['services'] ); |
|
| 714 | + $this->validate_aspects_services( $input[ 'services' ] ); |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | // Reset to defaults. |
| 718 | - if ( isset( $input['reset_defaults'] ) ) { |
|
| 718 | + if ( isset( $input[ 'reset_defaults' ] ) ) { |
|
| 719 | 719 | // Set the input to the default options. |
| 720 | 720 | $input = self::$_default_options; |
| 721 | 721 | |
| 722 | 722 | // Don't reset the fetched lists of pods, aspects and services. |
| 723 | - unset( $input['pod_list'] ); |
|
| 724 | - unset( $input['aspects_list'] ); |
|
| 725 | - unset( $input['services_list'] ); |
|
| 723 | + unset( $input[ 'pod_list' ] ); |
|
| 724 | + unset( $input[ 'aspects_list' ] ); |
|
| 725 | + unset( $input[ 'services_list' ] ); |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | // Unset all unused input fields. |
| 729 | - unset( $input['submit_defaults'] ); |
|
| 730 | - unset( $input['reset_defaults'] ); |
|
| 731 | - unset( $input['submit_setup'] ); |
|
| 729 | + unset( $input[ 'submit_defaults' ] ); |
|
| 730 | + unset( $input[ 'reset_defaults' ] ); |
|
| 731 | + unset( $input[ 'submit_setup' ] ); |
|
| 732 | 732 | |
| 733 | 733 | // Parse inputs with default options and return. |
| 734 | 734 | return wp_parse_args( $input, array_merge( self::$_default_options, self::$_options ) ); |
@@ -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"> |
@@ -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 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | private function _constants() { |
| 100 | 100 | // Are we in debugging mode? |
| 101 | - if ( isset( $_GET['debugging'] ) ) { |
|
| 101 | + if ( isset( $_GET[ 'debugging' ] ) ) { |
|
| 102 | 102 | define( 'WP2D_DEBUGGING', true ); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | private function _version_check() { |
| 118 | 118 | // Check for version requirements. |
| 119 | - if ( version_compare( $GLOBALS['wp_version'], $this->_min_wp, '<' ) |
|
| 119 | + if ( version_compare( $GLOBALS[ 'wp_version' ], $this->_min_wp, '<' ) |
|
| 120 | 120 | || version_compare( PHP_VERSION, $this->_min_php, '<' ) ) { |
| 121 | 121 | add_action( 'admin_notices', array( $this, 'deactivate' ) ); |
| 122 | 122 | return false; |
@@ -135,12 +135,12 @@ discard block |
||
| 135 | 135 | deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 136 | 136 | |
| 137 | 137 | // Get rid of the "Plugin activated" message. |
| 138 | - unset( $_GET['activate'] ); |
|
| 138 | + unset( $_GET[ 'activate' ] ); |
|
| 139 | 139 | |
| 140 | 140 | // Then display the admin notice. |
| 141 | 141 | ?> |
| 142 | 142 | <div class="error"> |
| 143 | - <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> |
|
| 143 | + <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 | 144 | </div> |
| 145 | 145 | <?php |
| 146 | 146 | } |
@@ -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 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | if ( isset( $pod_list->pods ) ) { |
| 314 | 314 | foreach ( $pod_list->pods as $pod ) { |
| 315 | 315 | if ( 'no' === $pod->hidden ) { |
| 316 | - $pods[] = array( |
|
| 316 | + $pods[ ] = array( |
|
| 317 | 317 | 'secure' => $pod->secure, |
| 318 | 318 | 'domain' => $pod->domain, |
| 319 | 319 | ); |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | * @todo esc_html |
| 421 | 421 | */ |
| 422 | 422 | public function check_pod_connection_status_callback() { |
| 423 | - if ( isset( $_REQUEST['debugging'] ) && ! defined( 'WP2D_DEBUGGING' ) ) { |
|
| 423 | + if ( isset( $_REQUEST[ 'debugging' ] ) && ! defined( 'WP2D_DEBUGGING' ) ) { |
|
| 424 | 424 | define( 'WP2D_DEBUGGING', true ); |
| 425 | 425 | } |
| 426 | 426 | |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | if ( true === $status ) { |
| 435 | 435 | wp_send_json_success( $data ); |
| 436 | 436 | } elseif ( false === $status && $this->_load_api()->has_last_error() ) { |
| 437 | - $data['message'] = $this->_load_api()->get_last_error() . ' ' . WP2D_Contextual_Help::get_help_tab_quick_link( $this->_load_api()->get_last_error_object() ); |
|
| 437 | + $data[ 'message' ] = $this->_load_api()->get_last_error() . ' ' . WP2D_Contextual_Help::get_help_tab_quick_link( $this->_load_api()->get_last_error_object() ); |
|
| 438 | 438 | wp_send_json_error( $data ); |
| 439 | 439 | } |
| 440 | 440 | // If $status === null, do nothing. |
@@ -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(); |
@@ -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 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | <ul> |
| 152 | 152 | <li><strong>' . esc_html__( 'Global tags', 'wp-to-diaspora' ) . '</strong>: ' . esc_html__( 'Tags that apply to all posts.', 'wp-to-diaspora' ) . ' |
| 153 | 153 | <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' ) . ' |
| 154 | - <li><strong>' . esc_html__( 'Post tags', 'wp-to-diaspora' ) . '</strong>: ' . esc_html__( 'Default WordPress Tags of individual posts.', 'wp-to-diaspora' ) . ' |
|
| 154 | + <li><strong>' . esc_html__( 'Post tags', 'wp-to-diaspora' ) . '</strong>: ' . esc_html__( 'Default WordPress Tags of individual posts.', 'wp-to-diaspora' ) . ' |
|
| 155 | 155 | </ul> |
| 156 | 156 | <li><strong>' . esc_html__( 'Global tags', 'wp-to-diaspora' ) . '</strong>: ' . |
| 157 | 157 | esc_html__( 'A list of tags that gets added to every post.', 'wp-to-diaspora' ) . ' |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | // Explain the importance of SSL connections to the pod and the CA certificate bundle. |
| 168 | 168 | $defined_functions = get_defined_functions(); |
| 169 | - $ssl_can_install = ( ! array_diff( array( 'fopen', 'fwrite', 'fclose', 'file_get_contents', 'file_put_contents' ), $defined_functions['internal'] ) ); |
|
| 169 | + $ssl_can_install = ( ! array_diff( array( 'fopen', 'fwrite', 'fclose', 'file_get_contents', 'file_put_contents' ), $defined_functions[ 'internal' ] ) ); |
|
| 170 | 170 | $ssl_cert_is_installed = ( file_exists( WP2D_DIR . '/cacert.pem' ) ); |
| 171 | 171 | |
| 172 | 172 | $ssl_install_output = ''; |
@@ -251,10 +251,10 @@ discard block |
||
| 251 | 251 | 'content' => '<p><strong>' . esc_html__( 'So you feel like contributing to the WP to diaspora* plugin? Great!', 'wp-to-diaspora' ) . '</strong></p> |
| 252 | 252 | <p>' . esc_html__( 'There are many different ways that you can help out with this plugin:', 'wp-to-diaspora' ) . '</p> |
| 253 | 253 | <ul> |
| 254 | - <li><a href="' . WP2D_EXT_GH_ISSUES_NEW . '" target="_blank">' . esc_html__( 'Report a bug', 'wp-to-diaspora' ) . '</a> |
|
| 255 | - <li><a href="' . WP2D_EXT_GH_ISSUES_NEW . '" target="_blank">' . esc_html__( 'Suggest a new feature', 'wp-to-diaspora' ) . '</a> |
|
| 256 | - <li><a href="' . WP2D_EXT_I18N . '" target="_blank">' . esc_html__( 'Help with translations', 'wp-to-diaspora' ) . '</a> |
|
| 257 | - <li><a href="' . WP2D_EXT_DONATE . '" target="_blank">' . esc_html__( 'Make a donation', 'wp-to-diaspora' ) . '</a> |
|
| 254 | + <li><a href="' . WP2D_EXT_GH_ISSUES_NEW . '" target="_blank">' . esc_html__( 'Report a bug', 'wp-to-diaspora' ) . '</a> |
|
| 255 | + <li><a href="' . WP2D_EXT_GH_ISSUES_NEW . '" target="_blank">' . esc_html__( 'Suggest a new feature', 'wp-to-diaspora' ) . '</a> |
|
| 256 | + <li><a href="' . WP2D_EXT_I18N . '" target="_blank">' . esc_html__( 'Help with translations', 'wp-to-diaspora' ) . '</a> |
|
| 257 | + <li><a href="' . WP2D_EXT_DONATE . '" target="_blank">' . esc_html__( 'Make a donation', 'wp-to-diaspora' ) . '</a> |
|
| 258 | 258 | </ul>', |
| 259 | 259 | ) ); |
| 260 | 260 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | public static function get_help_tab_quick_link( $error ) { |
| 285 | 285 | $help_tab = ''; |
| 286 | 286 | if ( is_wp_error( $error ) && ( $error_data = $error->get_error_data() ) && array_key_exists( 'help_tab', $error_data ) ) { |
| 287 | - $help_tab = $error_data['help_tab']; |
|
| 287 | + $help_tab = $error_data[ 'help_tab' ]; |
|
| 288 | 288 | } elseif ( is_string( $error ) ) { |
| 289 | 289 | $help_tab = $error; |
| 290 | 290 | } |