@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @param array $links Links to display for plugin on plugins page. |
334 | 334 | * |
335 | - * @return array Links to display for plugin on plugins page. |
|
335 | + * @return string[] Links to display for plugin on plugins page. |
|
336 | 336 | */ |
337 | 337 | public function settings_link( $links ) { |
338 | 338 | $links[] = '<a href="' . admin_url( 'options-general.php?page=wp_to_diaspora' ) . '">' . __( 'Settings' ) . '</a>'; |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | /** |
408 | 408 | * Check the pod connection status. |
409 | 409 | * |
410 | - * @return bool The status of the connection. |
|
410 | + * @return boolean|null The status of the connection. |
|
411 | 411 | */ |
412 | 412 | private function _check_pod_connection_status() { |
413 | 413 | $options = WP2D_Options::instance(); |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | 'content' => '<p><strong>' . esc_html__( 'Enter your diaspora* login details to connect your account.', 'wp-to-diaspora' ) . '</strong></p> |
124 | 124 | <ul> |
125 | 125 | <li><strong>' . esc_html__( 'diaspora* Pod', 'wp-to-diaspora' ) . '</strong>: ' . |
126 | - esc_html__( 'This is the domain name of the pod you are on (e.g. joindiaspora.com)', 'wp-to-diaspora' ) . ' |
|
126 | + esc_html__( 'This is the domain name of the pod you are on (e.g. joindiaspora.com)', 'wp-to-diaspora' ) . ' |
|
127 | 127 | <li><strong>' . esc_html__( 'Username', 'wp-to-diaspora' ) . '</strong>: ' . |
128 | - esc_html__( 'Your diaspora* username (without the pod domain).', 'wp-to-diaspora' ) . ' |
|
128 | + esc_html__( 'Your diaspora* username (without the pod domain).', 'wp-to-diaspora' ) . ' |
|
129 | 129 | <li><strong>' . esc_html__( 'Password', 'wp-to-diaspora' ) . '</strong>: ' . |
130 | - esc_html__( 'Your diaspora* password.', 'wp-to-diaspora' ) . ' |
|
130 | + esc_html__( 'Your diaspora* password.', 'wp-to-diaspora' ) . ' |
|
131 | 131 | </ul>', |
132 | 132 | ] ); |
133 | 133 | |
@@ -138,27 +138,27 @@ discard block |
||
138 | 138 | 'content' => '<p><strong>' . esc_html__( 'Define the default posting behaviour.', 'wp-to-diaspora' ) . '</strong></p> |
139 | 139 | <ul> |
140 | 140 | <li><strong>' . esc_html__( 'Post types', 'wp-to-diaspora' ) . '</strong>: ' . |
141 | - esc_html__( 'Choose the post types that are allowed to be shared to diaspora*.', 'wp-to-diaspora' ) . ' |
|
141 | + esc_html__( 'Choose the post types that are allowed to be shared to diaspora*.', 'wp-to-diaspora' ) . ' |
|
142 | 142 | <li><strong>' . esc_html__( 'Post to diaspora*', 'wp-to-diaspora' ) . '</strong>: ' . |
143 | - esc_html__( 'Automatically share new posts to diaspora* when publishing them.', 'wp-to-diaspora' ) . ' |
|
143 | + esc_html__( 'Automatically share new posts to diaspora* when publishing them.', 'wp-to-diaspora' ) . ' |
|
144 | 144 | <li><strong>' . esc_html__( 'Show "Posted at" link?', 'wp-to-diaspora' ) . '</strong>: ' . |
145 | - esc_html__( 'Add a link back to your original post, at the bottom of the diaspora* post.', 'wp-to-diaspora' ) . ' |
|
145 | + esc_html__( 'Add a link back to your original post, at the bottom of the diaspora* post.', 'wp-to-diaspora' ) . ' |
|
146 | 146 | <li><strong>' . esc_html__( 'Display', 'wp-to-diaspora' ) . '</strong>: ' . |
147 | - esc_html__( 'Choose whether you would like to post the whole post or just the excerpt.', 'wp-to-diaspora' ) . ' |
|
147 | + esc_html__( 'Choose whether you would like to post the whole post or just the excerpt.', 'wp-to-diaspora' ) . ' |
|
148 | 148 | <li><strong>' . esc_html__( 'Tags to post', 'wp-to-diaspora' ) . '</strong>: ' . |
149 | - esc_html__( 'You can add tags to your post to make it easier to find on diaspora*.' ) . '<br> |
|
149 | + esc_html__( 'You can add tags to your post to make it easier to find on diaspora*.' ) . '<br> |
|
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 | 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 | - esc_html__( 'A list of tags that gets added to every post.', 'wp-to-diaspora' ) . ' |
|
156 | + esc_html__( 'A list of tags that gets added to every post.', 'wp-to-diaspora' ) . ' |
|
157 | 157 | <li><strong>' . esc_html__( 'Aspects', 'wp-to-diaspora' ) . '</strong>: ' . |
158 | - esc_html__( 'Decide which of your diaspora* aspects can see your posts.', 'wp-to-diaspora' ) . '<br> |
|
158 | + esc_html__( 'Decide which of your diaspora* aspects can see your posts.', 'wp-to-diaspora' ) . '<br> |
|
159 | 159 | <em>' . sprintf( esc_html__( 'Use the "%s" button to load your aspects from diaspora*.', 'wp-to-diaspora' ), esc_html__( 'Refresh Aspects', 'wp-to-diaspora' ) ) . '</em> |
160 | 160 | <li><strong>' . esc_html__( 'Services', 'wp-to-diaspora' ) . '</strong>: ' . |
161 | - esc_html__( 'Choose the services your new diaspora* post gets shared to.', 'wp-to-diaspora' ) . '<br> |
|
161 | + esc_html__( 'Choose the services your new diaspora* post gets shared to.', 'wp-to-diaspora' ) . '<br> |
|
162 | 162 | <em>' . sprintf( esc_html__( 'Use the "%s" button to fetch the list of your connected services from diaspora*.', 'wp-to-diaspora' ), esc_html__( 'Refresh Services', 'wp-to-diaspora' ) ) . '</em> |
163 | 163 | </ul>', |
164 | 164 | ] ); |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | <p>' . esc_html__( 'There are a few important differences to the settings page:', 'wp-to-diaspora' ) . '</p> |
183 | 183 | <ul> |
184 | 184 | <li><strong>' . esc_html__( 'Already posted to diaspora*', 'wp-to-diaspora' ) . '</strong>: ' . |
185 | - esc_html__( 'If the post has already been posted to diaspora* a link to the diaspora* post will appear at the top.', 'wp-to-diaspora' ) . ' |
|
185 | + esc_html__( 'If the post has already been posted to diaspora* a link to the diaspora* post will appear at the top.', 'wp-to-diaspora' ) . ' |
|
186 | 186 | <li><strong>' . esc_html__( 'Custom tags', 'wp-to-diaspora' ) . '</strong>: ' . |
187 | - esc_html__( 'A list of tags that gets added to this post. Note that they are seperate from the WordPress post tags!', 'wp-to-diaspora' ) . ' |
|
187 | + esc_html__( 'A list of tags that gets added to this post. Note that they are seperate from the WordPress post tags!', 'wp-to-diaspora' ) . ' |
|
188 | 188 | </ul> |
189 | 189 | <p class="dashicons-before dashicons-info">' . esc_html__( 'If you don\'t see the meta box, make sure the post type you\'re on has been added to the "Post types" list on the settings page. Also make sure it has been selected from the "Screen Options" at the top of the screen.', 'wp-to-diaspora' ) . '</p>', |
190 | 190 | ] ); |
@@ -197,19 +197,19 @@ discard block |
||
197 | 197 | <p>' . esc_html__( 'Here are a few common errors and their possible solutions:', 'wp-to-diaspora' ) . '</p> |
198 | 198 | <ul> |
199 | 199 | <li><strong>' . esc_html( sprintf( __( 'Failed to initialise connection to pod "%s"', 'wp-to-diaspora' ), 'xyz' ) ) . '</strong>: ' . |
200 | - esc_html__( 'This could have multiple reasons.' ) . ' |
|
200 | + esc_html__( 'This could have multiple reasons.' ) . ' |
|
201 | 201 | <ul> |
202 | 202 | <li>' . esc_html__( 'Make sure that your pod domain is entered correctly.', 'wp-to-diaspora' ) . ' |
203 | 203 | <li>' . |
204 | - esc_html__( 'It might be an SSL problem.', 'wp-to-diaspora' ) . |
|
205 | - sprintf( ' <a href="https://github.com/DiasPHPora/wp-to-diaspora/wiki/SSL-and-TLS-Issues" class="open-help-tab" data-help-tab="ssl">%s</a>', esc_html__( 'Learn more', 'wp-to-diaspora' ) ) . ' |
|
204 | + esc_html__( 'It might be an SSL problem.', 'wp-to-diaspora' ) . |
|
205 | + sprintf( ' <a href="https://github.com/DiasPHPora/wp-to-diaspora/wiki/SSL-and-TLS-Issues" class="open-help-tab" data-help-tab="ssl">%s</a>', esc_html__( 'Learn more', 'wp-to-diaspora' ) ) . ' |
|
206 | 206 | <li>' . esc_html__( 'The pod might be offline at the moment.', 'wp-to-diaspora' ) . ' |
207 | 207 | </ul> |
208 | 208 | <li><strong>' . esc_html__( 'Login failed. Check your login details.', 'wp-to-diaspora' ) . '</strong>: ' . |
209 | - esc_html__( 'Make sure that your username and password are entered correctly.', 'wp-to-diaspora' ) . ' |
|
209 | + esc_html__( 'Make sure that your username and password are entered correctly.', 'wp-to-diaspora' ) . ' |
|
210 | 210 | <li><strong>' . esc_html__( 'Invalid credentials. Please re-save your login info.', 'wp-to-diaspora' ) . '</strong>: ' . |
211 | - esc_html__( 'This may be due to defining WP2D_ENC_KEY after upgrading to 2.2.0, which saves a new encrypted version of your password.', 'wp-to-diaspora' ) . |
|
212 | - sprintf( ' <a href="https://github.com/DiasPHPora/wp-to-diaspora/wiki/Configuration#wp2d_enc_key-since-220" target="_blank">%s</a>', esc_html__( 'Learn more', 'wp-to-diaspora' ) ) . ' |
|
211 | + esc_html__( 'This may be due to defining WP2D_ENC_KEY after upgrading to 2.2.0, which saves a new encrypted version of your password.', 'wp-to-diaspora' ) . |
|
212 | + sprintf( ' <a href="https://github.com/DiasPHPora/wp-to-diaspora/wiki/Configuration#wp2d_enc_key-since-220" target="_blank">%s</a>', esc_html__( 'Learn more', 'wp-to-diaspora' ) ) . ' |
|
213 | 213 | </ul>', |
214 | 214 | ] ); |
215 | 215 |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | * @var array |
28 | 28 | */ |
29 | 29 | private static $_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 | ]; |
@@ -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' ) { |
109 | - $tab = ( isset ( $_GET['tab'] ) ? $_GET['tab'] : $default ); |
|
109 | + $tab = ( isset ( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : $default ); |
|
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 ) { |
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' ) . '" /> '; |
@@ -773,14 +773,14 @@ discard block |
||
773 | 773 | esc_url( 'https://' . $this->get_option( 'pod' ) . '/services' ), |
774 | 774 | esc_html__( 'Show available services on my pod.', 'wp-to-diaspora' ) |
775 | 775 | ); |
776 | - $empty_label = esc_html__( 'No services connected yet.', 'wp-to-diaspora' ); |
|
776 | + $empty_label = esc_html__( 'No services connected yet.', 'wp-to-diaspora' ); |
|
777 | 777 | break; |
778 | 778 | |
779 | 779 | default: |
780 | 780 | return; |
781 | 781 | } |
782 | 782 | |
783 | - $items = array_filter( (array) $items ) ?: []; |
|
783 | + $items = array_filter( (array) $items ) ? : [ ]; |
|
784 | 784 | |
785 | 785 | // Special case for this field if it's displayed on the settings page. |
786 | 786 | $on_settings_page = ( 'settings_page_wp_to_diaspora' === get_current_screen()->id ); |
@@ -930,19 +930,19 @@ discard block |
||
930 | 930 | /* Validate all settings before saving to the database. */ |
931 | 931 | |
932 | 932 | // Saving the pod setup details. |
933 | - if ( isset( $input['submit_setup'] ) ) { |
|
934 | - $input['pod'] = trim( sanitize_text_field( $input['pod'] ), ' /' ); |
|
935 | - $input['username'] = sanitize_text_field( $input['username'] ); |
|
936 | - $input['password'] = sanitize_text_field( $input['password'] ); |
|
933 | + if ( isset( $input[ 'submit_setup' ] ) ) { |
|
934 | + $input[ 'pod' ] = trim( sanitize_text_field( $input[ 'pod' ] ), ' /' ); |
|
935 | + $input[ 'username' ] = sanitize_text_field( $input[ 'username' ] ); |
|
936 | + $input[ 'password' ] = sanitize_text_field( $input[ 'password' ] ); |
|
937 | 937 | |
938 | 938 | // If password is blank, it hasn't been changed. |
939 | 939 | // 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. |
940 | - if ( '' === $input['password'] || $this->get_option( 'password' ) === $input['password'] ) { |
|
940 | + if ( '' === $input[ 'password' ] || $this->get_option( 'password' ) === $input[ 'password' ] ) { |
|
941 | 941 | // Attempt a password upgrade if applicable. |
942 | 942 | $this->attempt_password_upgrade( true ); |
943 | - $input['password'] = $this->get_option( 'password' ); |
|
943 | + $input[ 'password' ] = $this->get_option( 'password' ); |
|
944 | 944 | } else { |
945 | - $input['password'] = WP2D_Helpers::encrypt( $input['password'] ); |
|
945 | + $input[ 'password' ] = WP2D_Helpers::encrypt( $input[ 'password' ] ); |
|
946 | 946 | } |
947 | 947 | |
948 | 948 | // Keep a note of the current AUTH_KEY. |
@@ -950,15 +950,15 @@ discard block |
||
950 | 950 | |
951 | 951 | // This is for when JS in not enabled, to make sure that the aspects and services |
952 | 952 | // are re-fetched when displaying the options page after saving. |
953 | - if ( isset( $input['no_js'] ) ) { |
|
953 | + if ( isset( $input[ 'no_js' ] ) ) { |
|
954 | 954 | set_transient( 'wp2d_no_js_force_refetch', true ); |
955 | 955 | } |
956 | 956 | } |
957 | 957 | |
958 | 958 | // Saving the default options. |
959 | - if ( isset( $input['submit_defaults'] ) ) { |
|
960 | - if ( ! isset( $input['enabled_post_types'] ) ) { |
|
961 | - $input['enabled_post_types'] = []; |
|
959 | + if ( isset( $input[ 'submit_defaults' ] ) ) { |
|
960 | + if ( ! isset( $input[ 'enabled_post_types' ] ) ) { |
|
961 | + $input[ 'enabled_post_types' ] = [ ]; |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | // Checkboxes. |
@@ -971,26 +971,26 @@ discard block |
||
971 | 971 | $this->validate_multi_selects( 'tags_to_post', $input ); |
972 | 972 | |
973 | 973 | // Get unique, non-empty, trimmed tags and clean them up. |
974 | - $this->validate_tags( $input['global_tags'] ); |
|
974 | + $this->validate_tags( $input[ 'global_tags' ] ); |
|
975 | 975 | |
976 | 976 | // Clean up the list of aspects. If the list is empty, only use the 'Public' aspect. |
977 | - $this->validate_aspects_services( $input['aspects'], [ 'public' ] ); |
|
977 | + $this->validate_aspects_services( $input[ 'aspects' ], [ 'public' ] ); |
|
978 | 978 | |
979 | 979 | // Clean up the list of services. |
980 | - $this->validate_aspects_services( $input['services'] ); |
|
980 | + $this->validate_aspects_services( $input[ 'services' ] ); |
|
981 | 981 | } |
982 | 982 | |
983 | 983 | // Reset to defaults. |
984 | - if ( isset( $input['reset_defaults'] ) ) { |
|
984 | + if ( isset( $input[ 'reset_defaults' ] ) ) { |
|
985 | 985 | // Set the input to the default options. |
986 | 986 | $input = self::$_default_options; |
987 | 987 | |
988 | 988 | // Don't reset the fetched lists of aspects and services. |
989 | - unset( $input['pod_list'], $input['aspects_list'], $input['services_list'] ); |
|
989 | + unset( $input[ 'pod_list' ], $input[ 'aspects_list' ], $input[ 'services_list' ] ); |
|
990 | 990 | } |
991 | 991 | |
992 | 992 | // Unset all unused input fields. |
993 | - unset( $input['submit_defaults'], $input['reset_defaults'], $input['submit_setup'] ); |
|
993 | + unset( $input[ 'submit_defaults' ], $input[ 'reset_defaults' ], $input[ 'submit_setup' ] ); |
|
994 | 994 | |
995 | 995 | // Parse inputs with default options and return. |
996 | 996 | return wp_parse_args( $input, array_merge( self::$_default_options, self::$_options ) ); |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | } |
1049 | 1049 | } |
1050 | 1050 | } else { |
1051 | - $options[ $select ] = []; |
|
1051 | + $options[ $select ] = [ ]; |
|
1052 | 1052 | } |
1053 | 1053 | } |
1054 | 1054 | |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | * |
1098 | 1098 | * @return array The validated list of aspects or services. |
1099 | 1099 | */ |
1100 | - public function validate_aspects_services( &$aspects_services, array $default = [] ) { |
|
1100 | + public function validate_aspects_services( &$aspects_services, array $default = [ ] ) { |
|
1101 | 1101 | if ( empty( $aspects_services ) || ! is_array( $aspects_services ) ) { |
1102 | 1102 | $aspects_services = $default; |
1103 | 1103 | } else { |