Skip to content
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
203 changes: 6 additions & 197 deletions MultisiteLanguageSwitcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Multisite Language Switcher Plugin
*
* Plugin Name: Multisite Language Switcher
* Version: 2.10.1
* Version: 3.0.0
* Plugin URI: http://msls.co/
* Description: A simple but powerful plugin that will help you to manage the relations of your contents in a multilingual multisite-installation.
* Author: Dennis Ploetner
Expand Down Expand Up @@ -45,205 +45,14 @@
* @author Dennis Ploetner <re@lloc.de>
*/
if ( ! defined( 'MSLS_PLUGIN_VERSION' ) ) {
define( 'MSLS_PLUGIN_VERSION', '2.10.1' );
define( 'MSLS_PLUGIN_VERSION', '3.0.0' );
define( 'MSLS_PLUGIN_PATH', plugin_basename( __FILE__ ) );
define( 'MSLS_PLUGIN__FILE__', __FILE__ );

require_once __DIR__ . '/includes/aliases.php';
require_once __DIR__ . '/includes/deprectated.php';
require_once __DIR__ . '/includes/api.php';

/**
* Get the output for using the links to the translations in your code
*
* @package Msls
* @param mixed $attr
* @return string
*/
function msls_get_switcher( $attr ): string {
$arr = is_array( $attr ) ? $attr : array();
$obj = apply_filters( 'msls_get_output', null );

return ! is_null( $obj ) ? strval( $obj->set_tags( $arr ) ) : '';
}

/**
* Output the links to the translations in your template
*
* You can call this function directly like that
*
* if ( function_exists ( 'the_msls' ) )
* the_msls();
*
* or just use it as shortcode [sc_msls]
*
* @package Msls
* @uses get_the_msls
*
* @param string[] $arr
*/
function msls_the_switcher( array $arr = array() ): void {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo msls_get_switcher( $arr );
}

/**
* Gets the URL of the country flag-icon for a specific locale
*
* @param string $locale
*
* @return string
*/
function msls_get_flag_url( string $locale ): string {
return ( new \lloc\Msls\MslsOptions() )->get_flag_url( $locale );
}

/**
* Gets the description for a blog for a specific locale
*
* @param string $locale
* @param string $preset
*
* @return string
*/
function msls_get_blog_description( string $locale, string $preset = '' ): string {
$blog = msls_blog( $locale );

return $blog ? $blog->get_description() : $preset;
}

/**
* Gets the permalink for a translation of the current post in a given language
*
* @param string $locale
* @param string $preset
*
* @return string
*/
function msls_get_permalink( string $locale, string $preset = '' ): string {
$url = null;
$blog = msls_blog( $locale );

if ( $blog ) {
$options = \lloc\Msls\MslsOptions::create();
$url = $blog->get_url( $options );
}

return $url ?? $preset;
}

/**
* Looks for the MslsBlog instance for a specific locale
*
* @param string $locale
*
* @return \lloc\Msls\MslsBlog|null
*/
function msls_blog( string $locale ): ?\lloc\Msls\MslsBlog {
return msls_blog_collection()->get_blog( $locale );
}

/**
* Gets the MslsBlogCollection instance
*
* @return \lloc\Msls\MslsBlogCollection
*/
function msls_blog_collection(): \lloc\Msls\MslsBlogCollection {
return \lloc\Msls\MslsBlogCollection::instance();
}

/**
* Gets the MslsOptions instance
*
* @return \lloc\Msls\MslsOptions
*/
function msls_options(): \lloc\Msls\MslsOptions {
return \lloc\Msls\MslsOptions::instance();
}

/**
* Gets the MslsContentTypes instance
*
* @return \lloc\Msls\MslsContentTypes
*/
function msls_content_types(): \lloc\Msls\MslsContentTypes {
return \lloc\Msls\MslsContentTypes::create();
}

/**
* Gets the MslsPostType instance
*
* @return \lloc\Msls\MslsPostType
*/
function msls_post_type(): \lloc\Msls\MslsPostType {
return \lloc\Msls\MslsPostType::instance();
}

/**
* Gets the MslsTaxonomy instance
*
* @return \lloc\Msls\MslsTaxonomy
*/
function msls_taxonomy(): \lloc\Msls\MslsTaxonomy {
return \lloc\Msls\MslsTaxonomy::instance();
}

/**
* Gets the MslsOutput instance
*
* @return \lloc\Msls\MslsOutput
*/
function msls_output(): \lloc\Msls\MslsOutput {
return \lloc\Msls\MslsOutput::create();
}

/**
* Retrieves the MslsOptionsPost instance.
*
* @param int $id
* @return \lloc\Msls\MslsOptionsPost
*/
function msls_get_post( int $id ): \lloc\Msls\MslsOptionsPost {
return new \lloc\Msls\MslsOptionsPost( $id );
}

/**
* Retrieves the MslsOptionsTax instance.
*
* Determines the current query based on conditional tags:
* - is_category
* - is_tag
* - is_tax
*
* @param int $id
* @return \lloc\Msls\OptionsTaxInterface
*/
function msls_get_tax( int $id ): \lloc\Msls\OptionsTaxInterface {
return \lloc\Msls\MslsOptionsTax::create( $id );
}

/**
* Retrieves the MslsOptionsQuery instance.
*
* Determines the current query based on conditional tags:
* - is_day
* - is_month
* - is_year
* - is_author
* - is_post_type_archive
*
* @return ?\lloc\Msls\MslsOptionsQuery
*/
function msls_get_query(): ?\lloc\Msls\MslsOptionsQuery {
return \lloc\Msls\MslsOptionsQuery::create();
}

/**
* Trivial void function for actions that do not return anything.
*
* @return void
*/
function msls_return_void(): void {
}

lloc\Msls\MslsPlugin::init();
lloc\Msls\MslsCli::init();
lloc\Msls\Plugin::init();
lloc\Msls\Cli\Cli::init();
}
22 changes: 11 additions & 11 deletions assets/css-flags/flags.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,21 @@
'cy' => 'flag-icon-gb-wls',
'da_DK' => 'flag-icon-dk',
'de_AT' => 'flag-icon-at',
'de_CH' => 'flag-icon-ch',
'de_DE' => 'flag-icon-de',
'de_DE_formal' => 'flag-icon-de',
'de_CH' => 'flag-icon-ch',
'de_CH_informal' => 'flag-icon-ch',
'dzo' => 'flag-icon-bt',
'el' => 'flag-icon-gr',
'en_NZ' => 'flag-icon-nz',
'en_CA' => 'flag-icon-ca',
'en_GB' => 'flag-icon-gb',
'en_AU' => 'flag-icon-au',
'en_ZA' => 'flag-icon-za',
'en_AU' => 'flag-icon-au',
'en_CA' => 'flag-icon-ca',
'eo' => 'flag-icon-eu',
'es_ES' => 'flag-icon-es',
'es_MX' => 'flag-icon-mx',
'es_CO' => 'flag-icon-co',
'es_CL' => 'flag-icon-cl',
'es_ES' => 'flag-icon-es',
'es_AR' => 'flag-icon-ar',
'es_CR' => 'flag-icon-cr',
'es_PE' => 'flag-icon-pe',
'es_VE' => 'flag-icon-ve',
Expand All @@ -57,14 +56,15 @@
'es_UY' => 'flag-icon-uy',
'es_PR' => 'flag-icon-pr',
'es_GT' => 'flag-icon-gt',
'es_AR' => 'flag-icon-ar',
'es_MX' => 'flag-icon-mx',
'es_CL' => 'flag-icon-cl',
'et' => 'flag-icon-ee',
'eu' => 'flag-icon-es',
'fa_IR' => 'flag-icon-ir',
'fa_AF' => 'flag-icon-af',
'fi' => 'flag-icon-fi',
'fr_CA' => 'flag-icon-ca',
'fr_FR' => 'flag-icon-fr',
'fr_CA' => 'flag-icon-ca',
'fr_BE' => 'flag-icon-be',
'fur' => 'flag-icon-it',
'gd' => 'flag-icon-gb-sct',
Expand Down Expand Up @@ -106,10 +106,10 @@
'pa_IN' => 'flag-icon-in',
'pl_PL' => 'flag-icon-pl',
'ps' => 'flag-icon-af',
'pt_PT_ao90' => 'flag-icon-90',
'pt_PT' => 'flag-icon-pt',
'pt_AO' => 'flag-icon-ao',
'pt_BR' => 'flag-icon-br',
'pt_AO' => 'flag-icon-ao',
'pt_PT_ao90' => 'flag-icon-90',
'ro_RO' => 'flag-icon-ro',
'ru_RU' => 'flag-icon-ru',
'sah' => 'flag-icon-ru',
Expand All @@ -135,8 +135,8 @@
'uz_UZ' => 'flag-icon-uz',
'vi' => 'flag-icon-vn',
'zh_TW' => 'flag-icon-tw',
'zh_HK' => 'flag-icon-hk',
'zh_CN' => 'flag-icon-cn',
'zh_HK' => 'flag-icon-hk',
);

/**
Expand Down
22 changes: 11 additions & 11 deletions assets/flags/flags.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,21 @@
'cy' => 'wales.png',
'da_DK' => 'dk.png',
'de_AT' => 'at.png',
'de_CH' => 'ch.png',
'de_DE' => 'de.png',
'de_DE_formal' => 'de.png',
'de_CH' => 'ch.png',
'de_CH_informal' => 'ch.png',
'dzo' => 'bt.png',
'el' => 'gr.png',
'en_NZ' => 'nz.png',
'en_CA' => 'ca.png',
'en_GB' => 'gb.png',
'en_AU' => 'au.png',
'en_ZA' => 'za.png',
'en_AU' => 'au.png',
'en_CA' => 'ca.png',
'eo' => 'europeanunion.png',
'es_ES' => 'es.png',
'es_MX' => 'mx.png',
'es_CO' => 'co.png',
'es_CL' => 'cl.png',
'es_ES' => 'es.png',
'es_AR' => 'ar.png',
'es_CR' => 'cr.png',
'es_PE' => 'pe.png',
'es_VE' => 've.png',
Expand All @@ -57,14 +56,15 @@
'es_UY' => 'uy.png',
'es_PR' => 'pr.png',
'es_GT' => 'gt.png',
'es_AR' => 'ar.png',
'es_MX' => 'mx.png',
'es_CL' => 'cl.png',
'et' => 'ee.png',
'eu' => 'es.png',
'fa_IR' => 'ir.png',
'fa_AF' => 'af.png',
'fi' => 'fi.png',
'fr_CA' => 'ca.png',
'fr_FR' => 'fr.png',
'fr_CA' => 'ca.png',
'fr_BE' => 'be.png',
'fur' => 'it.png',
'gd' => 'scotland.png',
Expand Down Expand Up @@ -106,10 +106,10 @@
'pa_IN' => 'in.png',
'pl_PL' => 'pl.png',
'ps' => 'af.png',
'pt_PT_ao90' => '90.png',
'pt_PT' => 'pt.png',
'pt_AO' => 'ao.png',
'pt_BR' => 'br.png',
'pt_AO' => 'ao.png',
'pt_PT_ao90' => '90.png',
'ro_RO' => 'ro.png',
'ru_RU' => 'ru.png',
'sah' => 'ru.png',
Expand All @@ -135,8 +135,8 @@
'uz_UZ' => 'uz.png',
'vi' => 'vn.png',
'zh_TW' => 'tw.png',
'zh_HK' => 'hk.png',
'zh_CN' => 'cn.png',
'zh_HK' => 'hk.png',
);

/**
Expand Down
2 changes: 1 addition & 1 deletion build/translations.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"flags-svg": "php bin/flags-svg.php > assets/css-flags/flags.php",
"git-release": "bin/git-release.sh",
"phpcs": "phpcs -p ./*.php includes/ --standard=vendor/phpcompatibility/php-compatibility/PHPCompatibility --runtime-set testVersion 7.4-",
"phpstan": "vendor/bin/phpstan analyze --memory-limit=1G",
"phpstan": "vendor/bin/phpstan analyze --memory-limit=2G",
"phpunit": "@php vendor/bin/phpunit",
"phpunit:clover": "@php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-clover tests/coverage.xml",
"phpunit:html": "@php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-html tests/coverage",
Expand Down
Loading