Skip to content

Refactoring version 2 8 #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@
/bin
/build
/docs
/githooks
/legacy-tests
/node_modules
/src
/tests
.distignore
.gitattributes
.gitignore
.scrutinizer.yml
Changelog.md
README.md
composer.json
composer.lock
package.json
package-lock.json
package.json
patchwork.json
phpcs.xml
phpdoc.xml
phpstan.neon
phpunit.xml
README.md
setup.sh
playwright.config.ts
setup.sh
24 changes: 12 additions & 12 deletions includes/MslsAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,21 @@ public function has_problems(): bool {
$message = '';

if ( $this->options->is_empty() ) {
$message = sprintf(
__(
'Multisite Language Switcher is almost ready. You must <a href="%s">complete the configuration process</a>.',
'multisite-language-switcher'
),
esc_url( admin_url( $this->get_options_page_link() ) )
/* translators: %s: URL to the options page */
$format = __(
'Multisite Language Switcher is almost ready. You must <a href="%s">complete the configuration process</a>.',
'multisite-language-switcher'
);
$message = sprintf( $format, esc_url( admin_url( $this->get_options_page_link() ) ) );
} elseif ( 1 == count( $this->options->get_available_languages() ) ) {
/* translators: %1$s: URL to a page at WordPress.orgs */
$format = __(
'TNo language files are currently installed. Learn how to install various languages in WordPress by <a href="%1$s">reading more here</a>.',
'multisite-language-switcher'
);
$message = sprintf(
__(
'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.',
'multisite-language-switcher'
),
esc_url( 'http://codex.wordpress.org/Installing_WordPress_in_Your_Language#Manually_Installing_Language_Files' ),
esc_url( 'http://wordpress.org/plugins/wp-native-dashboard/' )
$format,
esc_url( 'https://developer.wordpress.org/advanced-administration/before-install/in-your-language/#Manually_Installing_Language_Files' )
);
}

Expand Down
7 changes: 0 additions & 7 deletions includes/MslsMetaBox.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?php declare( strict_types=1 );

/**
* MslsMetaBox
*
* @author Dennis Ploetner <[email protected]>
* @since 0.9.8
*/

namespace lloc\Msls;

use lloc\Msls\ContentImport\MetaBox as ContentImportMetaBox;
Expand Down
45 changes: 24 additions & 21 deletions includes/MslsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,17 @@ public static function init() {
add_action(
'admin_notices',
function () {
$href = 'https://wordpress.org/support/article/create-a-network/';
$msg = sprintf(
__(
'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.',
'multisite-language-switcher'
),
$href
/* translators: %s: URL to the WordPress Codex. */
$format = __(
'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.',
'multisite-language-switcher'
);
$message = sprintf(
$format,
esc_url( 'https://developer.wordpress.org/advanced-administration/multisite/create-network/' )
);

self::message_handler( $msg );
self::message_handler( $message );
}
);
}
Expand Down Expand Up @@ -150,8 +151,10 @@ public function content_filter( string $content ) {
* @return string
*/
public function filter_string( $pref = '<p id="msls">', $post = '</p>' ) {
$obj = MslsOutput::init();
$links = $obj->get( 1, true, true );
$obj = MslsOutput::init();
$links = $obj->get( 1, true, true );

/* translators: %s: list of languages */
$output = __( 'This post is also available in %s.', 'multisite-language-switcher' );

if ( has_filter( 'msls_filter_string' ) ) {
Expand All @@ -164,25 +167,25 @@ public function filter_string( $pref = '<p id="msls">', $post = '</p>' ) {
* @since 1.0
*/
$output = apply_filters( 'msls_filter_string', $output, $links );
} else {
$output = '';
} elseif ( count( $links ) > 1 ) {
$last = array_pop( $links );

/* translators: %1$s: list of languages separated by a comma, %2$s: last language */
$format = __( '%1$s and %2$s', 'multisite-language-switcher' );

if ( count( $links ) > 1 ) {
$last = array_pop( $links );
$output = sprintf(
$output,
sprintf(
__( '%1$s and %2$s', 'multisite-language-switcher' ),
$format,
implode( ', ', $links ),
$last
)
);
} elseif ( 1 == count( $links ) ) {
$output = sprintf(
$output,
$links[0]
);
}
} elseif ( 1 == count( $links ) ) {
$output = sprintf(
$output,
$links[0]
);
}

return ! empty( $output ) ? $pref . $output . $post : '';
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/TestMslsMetaBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected function setUp(): void {
}

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

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

Expand Down
Loading