Skip to content

Commit a31aefb

Browse files
authored
Merge pull request #325 from lloc/refactoring-version-2-8
Refactoring version 2 8
2 parents b144b2e + 5c7443b commit a31aefb

File tree

5 files changed

+46
-44
lines changed

5 files changed

+46
-44
lines changed

.distignore

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,25 @@
44
/bin
55
/build
66
/docs
7+
/githooks
78
/legacy-tests
89
/node_modules
10+
/src
911
/tests
1012
.distignore
1113
.gitattributes
1214
.gitignore
1315
.scrutinizer.yml
1416
Changelog.md
17+
README.md
1518
composer.json
1619
composer.lock
17-
package.json
1820
package-lock.json
21+
package.json
22+
patchwork.json
23+
phpcs.xml
1924
phpdoc.xml
25+
phpstan.neon
2026
phpunit.xml
21-
README.md
22-
setup.sh
27+
playwright.config.ts
28+
setup.sh

includes/MslsAdmin.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,21 @@ public function has_problems(): bool {
137137
$message = '';
138138

139139
if ( $this->options->is_empty() ) {
140-
$message = sprintf(
141-
__(
142-
'Multisite Language Switcher is almost ready. You must <a href="%s">complete the configuration process</a>.',
143-
'multisite-language-switcher'
144-
),
145-
esc_url( admin_url( $this->get_options_page_link() ) )
140+
/* translators: %s: URL to the options page */
141+
$format = __(
142+
'Multisite Language Switcher is almost ready. You must <a href="%s">complete the configuration process</a>.',
143+
'multisite-language-switcher'
146144
);
145+
$message = sprintf( $format, esc_url( admin_url( $this->get_options_page_link() ) ) );
147146
} elseif ( 1 == count( $this->options->get_available_languages() ) ) {
147+
/* translators: %1$s: URL to a page at WordPress.orgs */
148+
$format = __(
149+
'TNo language files are currently installed. Learn how to install various languages in WordPress by <a href="%1$s">reading more here</a>.',
150+
'multisite-language-switcher'
151+
);
148152
$message = sprintf(
149-
__(
150-
'There are no language files installed. You can <a href="%1$s">manually install some language files</a> or you could use a <a href="%2$s">plugin</a> to download these files automatically.',
151-
'multisite-language-switcher'
152-
),
153-
esc_url( 'http://codex.wordpress.org/Installing_WordPress_in_Your_Language#Manually_Installing_Language_Files' ),
154-
esc_url( 'http://wordpress.org/plugins/wp-native-dashboard/' )
153+
$format,
154+
esc_url( 'https://developer.wordpress.org/advanced-administration/before-install/in-your-language/#Manually_Installing_Language_Files' )
155155
);
156156
}
157157

includes/MslsMetaBox.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
<?php declare( strict_types=1 );
22

3-
/**
4-
* MslsMetaBox
5-
*
6-
* @author Dennis Ploetner <re@lloc.de>
7-
* @since 0.9.8
8-
*/
9-
103
namespace lloc\Msls;
114

125
use lloc\Msls\ContentImport\MetaBox as ContentImportMetaBox;

includes/MslsPlugin.php

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,17 @@ public static function init() {
8787
add_action(
8888
'admin_notices',
8989
function () {
90-
$href = 'https://wordpress.org/support/article/create-a-network/';
91-
$msg = sprintf(
92-
__(
93-
'The Multisite Language Switcher needs the activation of the multisite-feature for working properly. Please read <a onclick="window.open(this.href); return false;" href="%s">this post</a> if you don\'t know the meaning.',
94-
'multisite-language-switcher'
95-
),
96-
$href
90+
/* translators: %s: URL to the WordPress Codex. */
91+
$format = __(
92+
'The Multisite Language Switcher needs the activation of the multisite-feature for working properly. Please read <a onclick="window.open(this.href); return false;" href="%s">this post</a> if you don\'t know the meaning.',
93+
'multisite-language-switcher'
94+
);
95+
$message = sprintf(
96+
$format,
97+
esc_url( 'https://developer.wordpress.org/advanced-administration/multisite/create-network/' )
9798
);
9899

99-
self::message_handler( $msg );
100+
self::message_handler( $message );
100101
}
101102
);
102103
}
@@ -150,8 +151,10 @@ public function content_filter( string $content ) {
150151
* @return string
151152
*/
152153
public function filter_string( $pref = '<p id="msls">', $post = '</p>' ) {
153-
$obj = MslsOutput::init();
154-
$links = $obj->get( 1, true, true );
154+
$obj = MslsOutput::init();
155+
$links = $obj->get( 1, true, true );
156+
157+
/* translators: %s: list of languages */
155158
$output = __( 'This post is also available in %s.', 'multisite-language-switcher' );
156159

157160
if ( has_filter( 'msls_filter_string' ) ) {
@@ -164,25 +167,25 @@ public function filter_string( $pref = '<p id="msls">', $post = '</p>' ) {
164167
* @since 1.0
165168
*/
166169
$output = apply_filters( 'msls_filter_string', $output, $links );
167-
} else {
168-
$output = '';
170+
} elseif ( count( $links ) > 1 ) {
171+
$last = array_pop( $links );
172+
173+
/* translators: %1$s: list of languages separated by a comma, %2$s: last language */
174+
$format = __( '%1$s and %2$s', 'multisite-language-switcher' );
169175

170-
if ( count( $links ) > 1 ) {
171-
$last = array_pop( $links );
172176
$output = sprintf(
173177
$output,
174178
sprintf(
175-
__( '%1$s and %2$s', 'multisite-language-switcher' ),
179+
$format,
176180
implode( ', ', $links ),
177181
$last
178182
)
179183
);
180-
} elseif ( 1 == count( $links ) ) {
181-
$output = sprintf(
182-
$output,
183-
$links[0]
184-
);
185-
}
184+
} elseif ( 1 == count( $links ) ) {
185+
$output = sprintf(
186+
$output,
187+
$links[0]
188+
);
186189
}
187190

188191
return ! empty( $output ) ? $pref . $output . $post : '';

tests/phpunit/TestMslsMetaBox.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protected function setUp(): void {
1818
}
1919

2020
public function test_suggest(): void {
21-
$json = json_encode( array( 'some' => 'JSON' ) );
21+
$json = '{"some":"JSON"}';
2222

2323
Functions\when( 'wp_die' )->justEcho( $json );
2424

0 commit comments

Comments
 (0)