@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | * @var array |
28 | 28 | */ |
29 | 29 | private static array $default_options = [ |
30 | - 'aspects_list' => [], |
|
31 | - 'services_list' => [], |
|
30 | + 'aspects_list' => [ ], |
|
31 | + 'services_list' => [ ], |
|
32 | 32 | 'post_to_diaspora' => true, |
33 | 33 | 'enabled_post_types' => [ 'post' ], |
34 | 34 | 'fullentrylink' => true, |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | 'tags_to_post' => [ 'global', 'custom', 'post' ], |
37 | 37 | 'global_tags' => '', |
38 | 38 | 'aspects' => [ 'public' ], |
39 | - 'services' => [], |
|
39 | + 'services' => [ ], |
|
40 | 40 | 'auth_key_hash' => '', |
41 | 41 | 'version' => WP2D_VERSION, |
42 | 42 | ]; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @var null|array |
58 | 58 | */ |
59 | - private static ?array $options = null; |
|
59 | + private static ? array $options = null; |
|
60 | 60 | |
61 | 61 | /** Singleton, keep private. */ |
62 | 62 | private function __clone() { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @return string Return the currently selected tab. |
107 | 107 | */ |
108 | 108 | private function current_tab( $default = 'defaults' ): string { |
109 | - $tab = sanitize_key( $_GET['tab'] ?? $default ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
109 | + $tab = sanitize_key( $_GET[ 'tab' ] ?? $default ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
110 | 110 | |
111 | 111 | // If the pod settings aren't configured yet, open the 'Setup' tab. |
112 | 112 | if ( ! $this->is_pod_set_up() ) { |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | */ |
126 | 126 | private function options_page_tabs( $return = false ): array { |
127 | 127 | // The array defining all options sections to be shown as tabs. |
128 | - $tabs = []; |
|
128 | + $tabs = [ ]; |
|
129 | 129 | if ( $this->is_pod_set_up() ) { |
130 | - $tabs['defaults'] = __( 'Defaults', 'wp-to-diaspora' ); |
|
130 | + $tabs[ 'defaults' ] = __( 'Defaults', 'wp-to-diaspora' ); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // Add the 'Setup' tab to the end of the list. |
134 | - $tabs['setup'] = __( 'Setup', 'wp-to-diaspora' ) . '<span id="pod-connection-status" class="dashicons-before hidden"></span><span class="spinner"></span>'; |
|
134 | + $tabs[ 'setup' ] = __( 'Setup', 'wp-to-diaspora' ) . '<span id="pod-connection-status" class="dashicons-before hidden"></span><span class="spinner"></span>'; |
|
135 | 135 | |
136 | 136 | // Container for all options tabs. |
137 | 137 | $out = '<h2 id="options-tabs" class="nav-tab-wrapper">'; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | return $tabs; |
150 | 150 | } |
151 | 151 | |
152 | - return []; |
|
152 | + return [ ]; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | do_settings_sections( 'wp_to_diaspora_settings' ); |
226 | 226 | |
227 | 227 | // Get the name of the current tab, if set, else take the first one from the list. |
228 | - $tab = $this->current_tab( $page_tabs[0] ); |
|
228 | + $tab = $this->current_tab( $page_tabs[ 0 ] ); |
|
229 | 229 | |
230 | 230 | // Add Save and Reset buttons. |
231 | 231 | 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', 'wp-to-diaspora' ) . '" /> '; |
@@ -512,14 +512,14 @@ discard block |
||
512 | 512 | esc_url( 'https://' . $this->get_option( 'pod' ) . '/services' ), |
513 | 513 | esc_html__( 'Show available services on my pod.', 'wp-to-diaspora' ) |
514 | 514 | ); |
515 | - $empty_label = esc_html__( 'No services connected yet.', 'wp-to-diaspora' ); |
|
515 | + $empty_label = esc_html__( 'No services connected yet.', 'wp-to-diaspora' ); |
|
516 | 516 | break; |
517 | 517 | |
518 | 518 | default: |
519 | 519 | return; |
520 | 520 | } |
521 | 521 | |
522 | - $items = array_filter( (array) $items ) ?: []; |
|
522 | + $items = array_filter( (array) $items ) ? : [ ]; |
|
523 | 523 | |
524 | 524 | // Special case for this field if it's displayed on the settings page. |
525 | 525 | $on_settings_page = ( 'settings_page_wp_to_diaspora' === get_current_screen()->id ); |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | return self::$valid_values[ $field ]; |
625 | 625 | } |
626 | 626 | |
627 | - return []; |
|
627 | + return [ ]; |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | /** |
@@ -672,19 +672,19 @@ discard block |
||
672 | 672 | /* Validate all settings before saving to the database. */ |
673 | 673 | |
674 | 674 | // Saving the pod setup details. |
675 | - if ( isset( $input['submit_setup'] ) ) { |
|
676 | - $input['pod'] = trim( sanitize_text_field( $input['pod'] ), ' /' ); |
|
677 | - $input['username'] = sanitize_text_field( $input['username'] ); |
|
678 | - $input['password'] = sanitize_text_field( $input['password'] ); |
|
675 | + if ( isset( $input[ 'submit_setup' ] ) ) { |
|
676 | + $input[ 'pod' ] = trim( sanitize_text_field( $input[ 'pod' ] ), ' /' ); |
|
677 | + $input[ 'username' ] = sanitize_text_field( $input[ 'username' ] ); |
|
678 | + $input[ 'password' ] = sanitize_text_field( $input[ 'password' ] ); |
|
679 | 679 | |
680 | 680 | // If password is blank, it hasn't been changed. |
681 | 681 | // 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. |
682 | - if ( '' === $input['password'] || $this->get_option( 'password' ) === $input['password'] ) { |
|
682 | + if ( '' === $input[ 'password' ] || $this->get_option( 'password' ) === $input[ 'password' ] ) { |
|
683 | 683 | // Attempt a password upgrade if applicable. |
684 | 684 | $this->attempt_password_upgrade( true ); |
685 | - $input['password'] = $this->get_option( 'password' ); |
|
685 | + $input[ 'password' ] = $this->get_option( 'password' ); |
|
686 | 686 | } else { |
687 | - $input['password'] = WP2D_Helpers::encrypt( $input['password'] ); |
|
687 | + $input[ 'password' ] = WP2D_Helpers::encrypt( $input[ 'password' ] ); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | // Keep a note of the current AUTH_KEY. |
@@ -692,15 +692,15 @@ discard block |
||
692 | 692 | |
693 | 693 | // This is for when JS in not enabled, to make sure that the aspects and services |
694 | 694 | // are re-fetched when displaying the options page after saving. |
695 | - if ( isset( $input['no_js'] ) ) { |
|
695 | + if ( isset( $input[ 'no_js' ] ) ) { |
|
696 | 696 | set_transient( 'wp2d_no_js_force_refetch', true ); |
697 | 697 | } |
698 | 698 | } |
699 | 699 | |
700 | 700 | // Saving the default options. |
701 | - if ( isset( $input['submit_defaults'] ) ) { |
|
702 | - if ( ! isset( $input['enabled_post_types'] ) ) { |
|
703 | - $input['enabled_post_types'] = []; |
|
701 | + if ( isset( $input[ 'submit_defaults' ] ) ) { |
|
702 | + if ( ! isset( $input[ 'enabled_post_types' ] ) ) { |
|
703 | + $input[ 'enabled_post_types' ] = [ ]; |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | // Checkboxes. |
@@ -713,26 +713,26 @@ discard block |
||
713 | 713 | $this->validate_multi_selects( 'tags_to_post', $input ); |
714 | 714 | |
715 | 715 | // Get unique, non-empty, trimmed tags and clean them up. |
716 | - $this->validate_tags( $input['global_tags'] ); |
|
716 | + $this->validate_tags( $input[ 'global_tags' ] ); |
|
717 | 717 | |
718 | 718 | // Clean up the list of aspects. If the list is empty, only use the 'Public' aspect. |
719 | - $this->validate_aspects_services( $input['aspects'] ?? [], [ 'public' ] ); |
|
719 | + $this->validate_aspects_services( $input[ 'aspects' ] ?? [ ], [ 'public' ] ); |
|
720 | 720 | |
721 | 721 | // Clean up the list of services. |
722 | - $this->validate_aspects_services( $input['services'] ?? [] ); |
|
722 | + $this->validate_aspects_services( $input[ 'services' ] ?? [ ] ); |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | // Reset to defaults. |
726 | - if ( isset( $input['reset_defaults'] ) ) { |
|
726 | + if ( isset( $input[ 'reset_defaults' ] ) ) { |
|
727 | 727 | // Set the input to the default options. |
728 | 728 | $input = self::$default_options; |
729 | 729 | |
730 | 730 | // Don't reset the fetched lists of aspects and services. |
731 | - unset( $input['pod_list'], $input['aspects_list'], $input['services_list'] ); |
|
731 | + unset( $input[ 'pod_list' ], $input[ 'aspects_list' ], $input[ 'services_list' ] ); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | // Unset all unused input fields. |
735 | - unset( $input['submit_defaults'], $input['reset_defaults'], $input['submit_setup'] ); |
|
735 | + unset( $input[ 'submit_defaults' ], $input[ 'reset_defaults' ], $input[ 'submit_setup' ] ); |
|
736 | 736 | |
737 | 737 | // Parse inputs with default options and return. |
738 | 738 | return wp_parse_args( $input, array_merge( self::$default_options, self::$options ) ); |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | } |
791 | 791 | } |
792 | 792 | } else { |
793 | - $options[ $select ] = []; |
|
793 | + $options[ $select ] = [ ]; |
|
794 | 794 | } |
795 | 795 | } |
796 | 796 | |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | * |
805 | 805 | * @return array The cleaned tags. |
806 | 806 | */ |
807 | - public function validate_tags( array|string &$tags ): array { |
|
807 | + public function validate_tags( array | string &$tags ): array { |
|
808 | 808 | WP2D_Helpers::str_to_arr( $tags ); |
809 | 809 | |
810 | 810 | $tags = array_map( [ $this, 'validate_tag' ], |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | * |
838 | 838 | * @return array The validated list of aspects or services. |
839 | 839 | */ |
840 | - public function validate_aspects_services( array $aspects_services, array $default = [] ): array { |
|
841 | - return array_map( 'sanitize_text_field', $aspects_services ) ?: $default; |
|
840 | + public function validate_aspects_services( array $aspects_services, array $default = [ ] ): array { |
|
841 | + return array_map( 'sanitize_text_field', $aspects_services ) ? : $default; |
|
842 | 842 | } |
843 | 843 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return bool|string The debug output. |
55 | 55 | */ |
56 | - public static function get_debugging(): bool|string { |
|
56 | + public static function get_debugging(): bool | string { |
|
57 | 57 | if ( defined( 'WP2D_DEBUGGING' ) && true === WP2D_DEBUGGING ) { |
58 | 58 | return self::$debugging; |
59 | 59 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return array The converted array. |
72 | 72 | */ |
73 | - public static function str_to_arr( array|string &$input ): array { |
|
73 | + public static function str_to_arr( array | string &$input ): array { |
|
74 | 74 | if ( ! is_array( $input ) ) { |
75 | 75 | // Explode string > Trim each entry > Remove blanks > Re-index array. |
76 | 76 | $input = array_values( array_filter( array_map( 'trim', explode( ',', $input ) ) ) ); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return string The converted string. |
94 | 94 | */ |
95 | - public static function arr_to_str( array|string &$input ): string { |
|
95 | + public static function arr_to_str( array | string &$input ): string { |
|
96 | 96 | if ( is_array( $input ) ) { |
97 | 97 | // Trim each entry > Remove blanks > Implode them together. |
98 | 98 | $input = implode( ',', array_filter( array_map( 'trim', array_filter( $input ) ) ) ); |
@@ -235,10 +235,10 @@ |
||
235 | 235 | * |
236 | 236 | * @return string HTML link. |
237 | 237 | */ |
238 | - public static function get_help_tab_quick_link( WP_Error|string $error ): string { |
|
238 | + public static function get_help_tab_quick_link( WP_Error | string $error ): string { |
|
239 | 239 | $help_tab = ''; |
240 | 240 | if ( is_wp_error( $error ) && ( $error_data = $error->get_error_data() ) && array_key_exists( 'help_tab', $error_data ) ) { |
241 | - $help_tab = $error_data['help_tab']; |
|
241 | + $help_tab = $error_data[ 'help_tab' ]; |
|
242 | 242 | } elseif ( is_string( $error ) ) { |
243 | 243 | $help_tab = $error; |
244 | 244 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @var array |
72 | 72 | */ |
73 | - public array $tags_to_post = []; |
|
73 | + public array $tags_to_post = [ ]; |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * The post's custom tags. |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @var array |
81 | 81 | */ |
82 | - public array $custom_tags = []; |
|
82 | + public array $custom_tags = [ ]; |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Aspects this post gets posted to. |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @var array |
90 | 90 | */ |
91 | - public array $aspects = []; |
|
91 | + public array $aspects = [ ]; |
|
92 | 92 | |
93 | 93 | /** |
94 | 94 | * Services this post gets posted to. |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @var array |
99 | 99 | */ |
100 | - public array $services = []; |
|
100 | + public array $services = [ ]; |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * The post's history of diaspora* posts. |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @var array |
108 | 108 | */ |
109 | - public array $post_history = []; |
|
109 | + public array $post_history = [ ]; |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * If the post actions have all been set up already. |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * |
154 | 154 | * @param int|WP_Post|null $post Post ID or the post itself. |
155 | 155 | */ |
156 | - public function __construct( int|WP_Post|null $post ) { |
|
156 | + public function __construct( int | WP_Post | null $post ) { |
|
157 | 157 | $this->assign_wp_post( $post ); |
158 | 158 | } |
159 | 159 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @param int|WP_Post|null $post Post ID or the post itself. |
166 | 166 | */ |
167 | - private function assign_wp_post( int|WP_Post|null $post ): void { |
|
167 | + private function assign_wp_post( int | WP_Post | null $post ): void { |
|
168 | 168 | if ( $this->post = get_post( $post ) ) { |
169 | 169 | $this->ID = $this->post->ID; |
170 | 170 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $this->post_to_diaspora = false; |
192 | 192 | } |
193 | 193 | |
194 | - $this->post_history = get_post_meta( $this->ID, '_wp_to_diaspora_post_history', true ) ?: []; |
|
194 | + $this->post_history = get_post_meta( $this->ID, '_wp_to_diaspora_post_history', true ) ? : [ ]; |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -229,7 +229,7 @@ discard block |
||
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(); |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | private function get_full_content(): string { |
321 | 321 | // Only allow certain shortcodes. |
322 | 322 | global $shortcode_tags; |
323 | - $shortcode_tags_bkp = []; |
|
323 | + $shortcode_tags_bkp = [ ]; |
|
324 | 324 | |
325 | 325 | foreach ( $shortcode_tags as $shortcode_tag => $shortcode_function ) { |
326 | 326 | if ( ! in_array( $shortcode_tag, apply_filters( 'wp2d_shortcodes_filter', [ 'wp_caption', 'caption', 'gallery' ] ), true ) ) { |
@@ -409,12 +409,12 @@ discard block |
||
409 | 409 | $options = WP2D_Options::instance(); |
410 | 410 | $tags_to_post = $this->tags_to_post; |
411 | 411 | $tags_to_add = ''; |
412 | - $diaspora_tags = []; |
|
412 | + $diaspora_tags = [ ]; |
|
413 | 413 | |
414 | 414 | // Add any diaspora* tags? |
415 | 415 | if ( ! empty( $tags_to_post ) ) { |
416 | 416 | // The diaspora* tags to add to the post. |
417 | - $diaspora_tags_tmp = []; |
|
417 | + $diaspora_tags_tmp = [ ]; |
|
418 | 418 | |
419 | 419 | // Add global tags? |
420 | 420 | $global_tags = $options->get_option( 'global_tags' ); |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | |
441 | 441 | // Get all the tags and list them all nicely in a row. |
442 | 442 | foreach ( $diaspora_tags_tmp as $tag ) { |
443 | - $diaspora_tags[] = '#' . $tag; |
|
443 | + $diaspora_tags[ ] = '#' . $tag; |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | // Add all the found tags. |
@@ -503,11 +503,11 @@ discard block |
||
503 | 503 | private function save_to_history( object $response ): void { |
504 | 504 | // Make sure the post history is an array. |
505 | 505 | if ( empty( $this->post_history ) ) { |
506 | - $this->post_history = []; |
|
506 | + $this->post_history = [ ]; |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | // Add a new entry to the history. |
510 | - $this->post_history[] = [ |
|
510 | + $this->post_history[ ] = [ |
|
511 | 511 | 'id' => $response->id, |
512 | 512 | 'guid' => $response->guid, |
513 | 513 | 'created_at' => $this->post->post_modified, |
@@ -594,8 +594,8 @@ discard block |
||
594 | 594 | $content = do_shortcode( $content ); |
595 | 595 | |
596 | 596 | // If a caption attribute is defined, we'll add it after the image. |
597 | - if ( isset( $attr['caption'] ) && '' !== $attr['caption'] ) { |
|
598 | - $content .= "\n" . $this->get_img_caption( $attr['caption'] ); |
|
597 | + if ( isset( $attr[ 'caption' ] ) && '' !== $attr[ 'caption' ] ) { |
|
598 | + $content .= "\n" . $this->get_img_caption( $attr[ 'caption' ] ); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | return $content; |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | */ |
613 | 613 | public function custom_gallery_shortcode( array $attr ): string { |
614 | 614 | // Try user value and fall back to default value in WordPress. |
615 | - $captiontag = $attr['captiontag'] ?? ( current_theme_supports( 'html5', 'gallery' ) ? 'figcaption' : 'dd' ); |
|
615 | + $captiontag = $attr[ 'captiontag' ] ?? ( current_theme_supports( 'html5', 'gallery' ) ? 'figcaption' : 'dd' ); |
|
616 | 616 | |
617 | 617 | // Let WordPress create the regular gallery. |
618 | 618 | $gallery = gallery_shortcode( $attr ); |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | * @return string Prettified gallery image caption. |
636 | 636 | */ |
637 | 637 | public function custom_gallery_regex_callback( array $m ): string { |
638 | - return $this->get_img_caption( $m[2] ); |
|
638 | + return $this->get_img_caption( $m[ 2 ] ); |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | /* |
@@ -680,14 +680,14 @@ discard block |
||
680 | 680 | |
681 | 681 | // If this post is already published, don't post again to diaspora* by default. |
682 | 682 | $this->post_to_diaspora = ( $this->post_to_diaspora && 'publish' !== get_post_status( $this->ID ) ); |
683 | - $this->aspects = $this->aspects ?: []; |
|
684 | - $this->services = $this->services ?: []; |
|
683 | + $this->aspects = $this->aspects ? : [ ]; |
|
684 | + $this->services = $this->services ? : [ ]; |
|
685 | 685 | |
686 | 686 | // Have we already posted on diaspora*? |
687 | 687 | $diaspora_post_url = '#'; |
688 | 688 | if ( $this->post_history ) { |
689 | 689 | $latest_post = end( $this->post_history ); |
690 | - $diaspora_post_url = $latest_post['post_url']; |
|
690 | + $diaspora_post_url = $latest_post[ 'post_url' ]; |
|
691 | 691 | } |
692 | 692 | ?> |
693 | 693 | <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> |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | /* OK, it's safe for us to save the data now. */ |
724 | 724 | |
725 | 725 | // Meta data to save. |
726 | - $meta_to_save = $_POST['wp_to_diaspora_settings']; // phpcs:ignore |
|
726 | + $meta_to_save = $_POST[ 'wp_to_diaspora_settings' ]; // phpcs:ignore |
|
727 | 727 | $options = WP2D_Options::instance(); |
728 | 728 | |
729 | 729 | // Checkboxes. |
@@ -736,13 +736,13 @@ discard block |
||
736 | 736 | $options->validate_multi_selects( 'tags_to_post', $meta_to_save ); |
737 | 737 | |
738 | 738 | // Save custom tags as array. |
739 | - $options->validate_tags( $meta_to_save['custom_tags'] ); |
|
739 | + $options->validate_tags( $meta_to_save[ 'custom_tags' ] ); |
|
740 | 740 | |
741 | 741 | // Clean up the list of aspects. If the list is empty, only use the 'Public' aspect. |
742 | - $options->validate_aspects_services( $meta_to_save['aspects'] ?? [], [ 'public' ] ); |
|
742 | + $options->validate_aspects_services( $meta_to_save[ 'aspects' ] ?? [ ], [ 'public' ] ); |
|
743 | 743 | |
744 | 744 | // Clean up the list of services. |
745 | - $options->validate_aspects_services( $meta_to_save['services'] ?? [] ); |
|
745 | + $options->validate_aspects_services( $meta_to_save[ 'services' ] ?? [ ] ); |
|
746 | 746 | |
747 | 747 | // Update the meta data for this post. |
748 | 748 | update_post_meta( $post_id, '_wp_to_diaspora', $meta_to_save ); |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | */ |
758 | 758 | private function is_safe_to_save(): bool { |
759 | 759 | // Verify that our nonce is set and valid. |
760 | - 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' ) ) ) { |
|
760 | + 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' ) ) ) { |
|
761 | 761 | return false; |
762 | 762 | } |
763 | 763 | |
@@ -767,13 +767,13 @@ discard block |
||
767 | 767 | } |
768 | 768 | |
769 | 769 | // Check the user's permissions. |
770 | - $permission = ( isset( $_POST['post_type'] ) && 'page' === $_POST['post_type'] ) ? 'edit_pages' : 'edit_posts'; |
|
770 | + $permission = ( isset( $_POST[ 'post_type' ] ) && 'page' === $_POST[ 'post_type' ] ) ? 'edit_pages' : 'edit_posts'; |
|
771 | 771 | if ( ! current_user_can( $permission, $this->ID ) ) { |
772 | 772 | return false; |
773 | 773 | } |
774 | 774 | |
775 | 775 | // Make real sure that we have some meta data to save. |
776 | - if ( ! isset( $_POST['wp_to_diaspora_settings'] ) ) { |
|
776 | + if ( ! isset( $_POST[ 'wp_to_diaspora_settings' ] ) ) { |
|
777 | 777 | return false; |
778 | 778 | } |
779 | 779 | |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | '<div class="error notice is-dismissible"><p>%1$s %2$s %3$s <a href="%4$s">%5$s</a></p></div>', |
803 | 803 | esc_html__( 'Failed to post to diaspora*.', 'wp-to-diaspora' ), |
804 | 804 | esc_html( $error->get_error_message() ), |
805 | - $help_link, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
805 | + $help_link, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
806 | 806 | esc_url( add_query_arg( 'wp2d_ignore_post_error', '' ) ), |
807 | 807 | esc_html__( 'Ignore', 'wp-to-diaspora' ) |
808 | 808 | ); |
@@ -811,11 +811,11 @@ discard block |
||
811 | 811 | $latest_post = end( $diaspora_post_history ); |
812 | 812 | |
813 | 813 | // Only show if this post is showing a message and the post is a fresh share. |
814 | - if ( isset( $_GET['message'] ) && $post->post_modified === $latest_post['created_at'] ) { // phpcs:ignore |
|
814 | + if ( isset( $_GET[ 'message' ] ) && $post->post_modified === $latest_post[ 'created_at' ] ) { // phpcs:ignore |
|
815 | 815 | printf( |
816 | 816 | '<div class="updated notice is-dismissible"><p>%1$s <a href="%2$s" target="_blank">%3$s</a></p></div>', |
817 | 817 | esc_html__( 'Successfully posted to diaspora*.', 'wp-to-diaspora' ), |
818 | - esc_url( $latest_post['post_url'] ), |
|
818 | + esc_url( $latest_post[ 'post_url' ] ), |
|
819 | 819 | esc_html__( 'View Post', 'wp-to-diaspora' ) |
820 | 820 | ); |
821 | 821 | } |
@@ -829,8 +829,8 @@ discard block |
||
829 | 829 | */ |
830 | 830 | public function ignore_post_error(): void { |
831 | 831 | // If "Ignore" link has been clicked, delete the post error meta data. |
832 | - if ( isset( $_GET['wp2d_ignore_post_error'], $_GET['post'] ) ) { // phpcs:ignore |
|
833 | - delete_post_meta( absint( $_GET['post'] ), '_wp_to_diaspora_post_error' ); // phpcs:ignore |
|
832 | + if ( isset( $_GET[ 'wp2d_ignore_post_error' ], $_GET[ 'post' ] ) ) { // phpcs:ignore |
|
833 | + delete_post_meta( absint( $_GET[ 'post' ] ), '_wp_to_diaspora_post_error' ); // phpcs:ignore |
|
834 | 834 | } |
835 | 835 | } |
836 | 836 | |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | ] ); |
847 | 847 | } |
848 | 848 | |
849 | - $post_id = sanitize_key( $_REQUEST['post_id'] ?? '' ); |
|
849 | + $post_id = sanitize_key( $_REQUEST[ 'post_id' ] ?? '' ); |
|
850 | 850 | if ( ! is_numeric( $post_id ) ) { |
851 | 851 | return; |
852 | 852 | } |
@@ -863,12 +863,12 @@ discard block |
||
863 | 863 | $latest_post = end( $diaspora_post_history ); |
864 | 864 | |
865 | 865 | // Only show if this post is a fresh share. |
866 | - if ( get_post( $post_id )->post_modified === $latest_post['created_at'] ) { // phpcs:ignore |
|
866 | + if ( get_post( $post_id )->post_modified === $latest_post[ 'created_at' ] ) { // phpcs:ignore |
|
867 | 867 | wp_send_json_success( [ |
868 | 868 | 'message' => esc_html__( 'Successfully posted to diaspora*.', 'wp-to-diaspora' ), |
869 | 869 | 'action' => [ |
870 | 870 | 'label' => esc_html__( 'View Post', 'wp-to-diaspora' ), |
871 | - 'url' => esc_url( $latest_post['post_url'] ), |
|
871 | + 'url' => esc_url( $latest_post[ 'post_url' ] ), |
|
872 | 872 | ], |
873 | 873 | ] ); |
874 | 874 | } |
@@ -811,7 +811,8 @@ discard block |
||
811 | 811 | $latest_post = end( $diaspora_post_history ); |
812 | 812 | |
813 | 813 | // Only show if this post is showing a message and the post is a fresh share. |
814 | - if ( isset( $_GET['message'] ) && $post->post_modified === $latest_post['created_at'] ) { // phpcs:ignore |
|
814 | + if ( isset( $_GET['message'] ) && $post->post_modified === $latest_post['created_at'] ) { |
|
815 | +// phpcs:ignore |
|
815 | 816 | printf( |
816 | 817 | '<div class="updated notice is-dismissible"><p>%1$s <a href="%2$s" target="_blank">%3$s</a></p></div>', |
817 | 818 | esc_html__( 'Successfully posted to diaspora*.', 'wp-to-diaspora' ), |
@@ -829,7 +830,8 @@ discard block |
||
829 | 830 | */ |
830 | 831 | public function ignore_post_error(): void { |
831 | 832 | // If "Ignore" link has been clicked, delete the post error meta data. |
832 | - if ( isset( $_GET['wp2d_ignore_post_error'], $_GET['post'] ) ) { // phpcs:ignore |
|
833 | + if ( isset( $_GET['wp2d_ignore_post_error'], $_GET['post'] ) ) { |
|
834 | +// phpcs:ignore |
|
833 | 835 | delete_post_meta( absint( $_GET['post'] ), '_wp_to_diaspora_post_error' ); // phpcs:ignore |
834 | 836 | } |
835 | 837 | } |
@@ -863,7 +865,8 @@ discard block |
||
863 | 865 | $latest_post = end( $diaspora_post_history ); |
864 | 866 | |
865 | 867 | // Only show if this post is a fresh share. |
866 | - if ( get_post( $post_id )->post_modified === $latest_post['created_at'] ) { // phpcs:ignore |
|
868 | + if ( get_post( $post_id )->post_modified === $latest_post['created_at'] ) { |
|
869 | +// phpcs:ignore |
|
867 | 870 | wp_send_json_success( [ |
868 | 871 | 'message' => esc_html__( 'Successfully posted to diaspora*.', 'wp-to-diaspora' ), |
869 | 872 | 'action' => [ |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * @var array The list of user's aspects, which get set after ever http request. |
84 | 84 | */ |
85 | - private array $aspects = []; |
|
85 | + private array $aspects = [ ]; |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * @var array The list of user's connected services, which get set after ever http request. |
89 | 89 | */ |
90 | - private array $services = []; |
|
90 | + private array $services = [ ]; |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @var array List of regex expressions used to filter out details from http request responses. |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | $this->is_logged_in = false; |
360 | 360 | $this->username = ''; |
361 | 361 | $this->password = ''; |
362 | - $this->aspects = []; |
|
363 | - $this->services = []; |
|
362 | + $this->aspects = [ ]; |
|
363 | + $this->services = [ ]; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * |
385 | 385 | * @return bool|object Return the response data of the new diaspora* post if successfully posted, else false. |
386 | 386 | */ |
387 | - public function post( string $text, array|string $aspects = 'public', array $extra_data = [] ): object|bool { |
|
387 | + public function post( string $text, array | string $aspects = 'public', array $extra_data = [ ] ): object | bool { |
|
388 | 388 | // Are we logged in? |
389 | 389 | if ( ! $this->check_login() ) { |
390 | 390 | return false; |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | * |
493 | 493 | * @return array|bool Array of aspect objects or false. |
494 | 494 | */ |
495 | - public function get_aspects( bool $force = false ): bool|array { |
|
495 | + public function get_aspects( bool $force = false ): bool | array { |
|
496 | 496 | $aspects = $this->get_aspects_services( 'aspects', $this->aspects, $force ); |
497 | 497 | if ( false !== $aspects ) { |
498 | 498 | $this->aspects = $aspects; |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @return array|bool Array of service objects or false. |
510 | 510 | */ |
511 | - public function get_services( bool $force = false ): bool|array { |
|
511 | + public function get_services( bool $force = false ): bool | array { |
|
512 | 512 | $services = $this->get_aspects_services( 'services', $this->services, $force ); |
513 | 513 | if ( false !== $services ) { |
514 | 514 | $this->services = $services; |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | * |
527 | 527 | * @return array|bool List of fetched aspects or services, or false. |
528 | 528 | */ |
529 | - private function get_aspects_services( string $type, array $list, bool $force ): bool|array { |
|
529 | + private function get_aspects_services( string $type, array $list, bool $force ): bool | array { |
|
530 | 530 | if ( ! $this->check_login() ) { |
531 | 531 | return false; |
532 | 532 | } |
@@ -550,11 +550,11 @@ discard block |
||
550 | 550 | // Load the aspects or services. |
551 | 551 | $raw_list = json_decode( $this->parse_regex( $type, (string) $response->getBody() ), false ); |
552 | 552 | if ( is_array( $raw_list ) ) { |
553 | - $list = []; |
|
553 | + $list = [ ]; |
|
554 | 554 | |
555 | 555 | if ( 'aspects' === $type ) { |
556 | 556 | // Add the 'public' aspect, as it's global and not user specific. |
557 | - $list['public'] = __( 'Public', 'wp-to-diaspora' ); |
|
557 | + $list[ 'public' ] = __( 'Public', 'wp-to-diaspora' ); |
|
558 | 558 | |
559 | 559 | // Add all user specific aspects. |
560 | 560 | foreach ( $raw_list as $aspect ) { |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | |
585 | 585 | $handler = apply_filters( 'wp2d_guzzle_handler', $handler ); |
586 | 586 | |
587 | - $handler->push( Middleware::mapRequest( function ( RequestInterface $request ) { |
|
587 | + $handler->push( Middleware::mapRequest( function( RequestInterface $request ) { |
|
588 | 588 | if ( 'DELETE' === $request->getMethod() || '/status_messages' === $request->getUri()->getPath() ) { |
589 | 589 | return $request |
590 | 590 | ->withHeader( 'Accept', 'application/json' ) |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | } ) ); |
597 | 597 | |
598 | 598 | // Save the most recent response and token after each request. |
599 | - $handler->push( Middleware::mapResponse( function ( ResponseInterface $response ) { |
|
599 | + $handler->push( Middleware::mapResponse( function( ResponseInterface $response ) { |
|
600 | 600 | $body = (string) $response->getBody(); |
601 | 601 | |
602 | 602 | if ( $csrf_token = $this->parse_regex( 'csrf_token', $body ) ) { |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | * @param string $message Error message. |
627 | 627 | * @param mixed $data Error data. |
628 | 628 | */ |
629 | - private function error( string|int $code, string $message, mixed $data = '' ): void { |
|
629 | + private function error( string | int $code, string $message, mixed $data = '' ): void { |
|
630 | 630 | // Always add the code and message of the last request. |
631 | 631 | $data = array_merge( array_filter( (array) $data ), [ |
632 | 632 | 'code' => $this->last_response?->getStatusCode(), |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | private function constants(): void { |
73 | 73 | // Are we in debugging mode? |
74 | - if ( isset( $_GET['debugging'] ) ) { // phpcs:ignore |
|
74 | + if ( isset( $_GET[ 'debugging' ] ) ) { // phpcs:ignore |
|
75 | 75 | define( 'WP2D_DEBUGGING', true ); |
76 | 76 | } |
77 | 77 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | private function version_check(): bool { |
93 | 93 | // Check for version requirements. |
94 | - if ( version_compare( PHP_VERSION, $this->min_php, '<' ) || version_compare( $GLOBALS['wp_version'], $this->min_wp, '<' ) ) { |
|
94 | + if ( version_compare( PHP_VERSION, $this->min_php, '<' ) || version_compare( $GLOBALS[ 'wp_version' ], $this->min_wp, '<' ) ) { |
|
95 | 95 | add_action( 'admin_notices', [ $this, 'deactivate' ] ); |
96 | 96 | |
97 | 97 | return false; |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | deactivate_plugins( WP2D_BASENAME ); |
111 | 111 | |
112 | 112 | // Get rid of the "Plugin activated" message. |
113 | - unset( $_GET['activate'] ); // phpcs:ignore |
|
113 | + unset( $_GET[ 'activate' ] ); // phpcs:ignore |
|
114 | 114 | |
115 | 115 | // Display the admin notice. |
116 | 116 | ?> |
117 | 117 | <div class="error"> |
118 | - <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> |
|
118 | + <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> |
|
119 | 119 | </div> |
120 | 120 | <?php |
121 | 121 | } |
@@ -221,16 +221,16 @@ discard block |
||
221 | 221 | */ |
222 | 222 | public function admin_load_scripts(): void { |
223 | 223 | // Get the enabled post types to load the script for. |
224 | - $enabled_post_types = WP2D_Options::instance()->get_option( 'enabled_post_types', [] ); |
|
224 | + $enabled_post_types = WP2D_Options::instance()->get_option( 'enabled_post_types', [ ] ); |
|
225 | 225 | |
226 | 226 | // Get the screen to find out where we are. |
227 | 227 | $screen = get_current_screen(); |
228 | 228 | |
229 | 229 | // Only load the styles and scripts on the settings page and the allowed post types. |
230 | 230 | if ( 'settings_page_wp_to_diaspora' === $screen?->id || ( 'post' === $screen?->base && in_array( $screen?->post_type, $enabled_post_types, true ) ) ) { |
231 | - wp_enqueue_style( 'tag-it', plugins_url( '/css/tag-it.min.css', WP2D_BASENAME ), [], WP2D_VERSION ); |
|
232 | - wp_enqueue_style( 'chosen', plugins_url( '/css/chosen.min.css', WP2D_BASENAME ), [], WP2D_VERSION ); |
|
233 | - wp_enqueue_style( 'wp-to-diaspora-admin', plugins_url( '/css/wp-to-diaspora.css', WP2D_BASENAME ), [], WP2D_VERSION ); |
|
231 | + wp_enqueue_style( 'tag-it', plugins_url( '/css/tag-it.min.css', WP2D_BASENAME ), [ ], WP2D_VERSION ); |
|
232 | + wp_enqueue_style( 'chosen', plugins_url( '/css/chosen.min.css', WP2D_BASENAME ), [ ], WP2D_VERSION ); |
|
233 | + wp_enqueue_style( 'wp-to-diaspora-admin', plugins_url( '/css/wp-to-diaspora.css', WP2D_BASENAME ), [ ], WP2D_VERSION ); |
|
234 | 234 | wp_enqueue_script( 'chosen', plugins_url( '/js/chosen.jquery.min.js', WP2D_BASENAME ), [ 'jquery' ], WP2D_VERSION, true ); |
235 | 235 | wp_enqueue_script( 'tag-it', plugins_url( '/js/tag-it.jquery.min.js', WP2D_BASENAME ), [ 'jquery', 'jquery-ui-autocomplete' ], WP2D_VERSION, true ); |
236 | 236 | wp_enqueue_script( 'wp-to-diaspora-admin', plugins_url( '/js/wp-to-diaspora.js', WP2D_BASENAME ), [ 'jquery' ], WP2D_VERSION, true ); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @return array Links to display for plugin on plugins page. |
282 | 282 | */ |
283 | 283 | public function settings_link( array $links ): array { |
284 | - $links[] = '<a href="' . esc_url( admin_url( 'options-general.php?page=wp_to_diaspora' ) ) . '">' . __( 'Settings', 'wp-to-diaspora' ) . '</a>'; |
|
284 | + $links[ ] = '<a href="' . esc_url( admin_url( 'options-general.php?page=wp_to_diaspora' ) ) . '">' . __( 'Settings', 'wp-to-diaspora' ) . '</a>'; |
|
285 | 285 | |
286 | 286 | return $links; |
287 | 287 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @return array|bool The list of aspects or services, false if an illegal parameter is passed. |
297 | 297 | */ |
298 | - private function update_aspects_services_list( string $type ): bool|array { |
|
298 | + private function update_aspects_services_list( string $type ): bool | array { |
|
299 | 299 | // Check for correct argument value. |
300 | 300 | if ( ! in_array( $type, [ 'aspects', 'services' ], true ) ) { |
301 | 301 | return false; |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | * @todo esc_html |
377 | 377 | */ |
378 | 378 | public function check_pod_connection_status_callback(): void { |
379 | - if ( ! defined( 'WP2D_DEBUGGING' ) && isset( $_REQUEST['debugging'] ) ) { // phpcs:ignore |
|
379 | + if ( ! defined( 'WP2D_DEBUGGING' ) && isset( $_REQUEST[ 'debugging' ] ) ) { // phpcs:ignore |
|
380 | 380 | define( 'WP2D_DEBUGGING', true ); |
381 | 381 | } |
382 | 382 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | if ( true === $status ) { |
395 | 395 | wp_send_json_success( $data ); |
396 | 396 | } elseif ( false === $status && $this->load_api()->has_last_error() ) { |
397 | - $data['message'] = $this->load_api()->get_last_error() . ' ' . WP2D_Contextual_Help::get_help_tab_quick_link( $this->load_api()->get_last_error_object() ); |
|
397 | + $data[ 'message' ] = $this->load_api()->get_last_error() . ' ' . WP2D_Contextual_Help::get_help_tab_quick_link( $this->load_api()->get_last_error_object() ); |
|
398 | 398 | wp_send_json_error( $data ); |
399 | 399 | } |
400 | 400 | // If $status === null, do nothing. |
@@ -71,7 +71,8 @@ discard block |
||
71 | 71 | */ |
72 | 72 | private function constants(): void { |
73 | 73 | // Are we in debugging mode? |
74 | - if ( isset( $_GET['debugging'] ) ) { // phpcs:ignore |
|
74 | + if ( isset( $_GET['debugging'] ) ) { |
|
75 | +// phpcs:ignore |
|
75 | 76 | define( 'WP2D_DEBUGGING', true ); |
76 | 77 | } |
77 | 78 | |
@@ -376,7 +377,8 @@ discard block |
||
376 | 377 | * @todo esc_html |
377 | 378 | */ |
378 | 379 | public function check_pod_connection_status_callback(): void { |
379 | - if ( ! defined( 'WP2D_DEBUGGING' ) && isset( $_REQUEST['debugging'] ) ) { // phpcs:ignore |
|
380 | + if ( ! defined( 'WP2D_DEBUGGING' ) && isset( $_REQUEST['debugging'] ) ) { |
|
381 | +// phpcs:ignore |
|
380 | 382 | define( 'WP2D_DEBUGGING', true ); |
381 | 383 | } |
382 | 384 |