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
19 changes: 11 additions & 8 deletions .distignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
/.wordpress-org
.distignore
.gitattributes
.gitignore
.phpcs.cache
.phpstan.neon.dist
.phpcs.xml.dist
.phpunit.result.cache
.scrutinizer.yml
/.git
/.github
/.idea
/.wordpress-org
/bin
/mslsselect
/reports
/tests
.distignore
.gitattributes
.gitignore
.scrutinizer.yml
Changelog.md
README.md
composer.json
composer.lock
mslsselect.zip
package.json
package-lock.json
package.json
phpdoc.xml
phpstan.neon
phpunit.xml
README.md

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.phpcs.cache
.phpunit.result.cache
composer.lock
phpunit.xml.bak
.phpunit.result.cache
.idea/
vendor/
coverage/
Expand Down
26 changes: 26 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<ruleset name="CS">
<description>PHPCS MslsMenu configuration</description>
<config name="testVersion" value="7.4-"/>
<exclude-pattern>bin/*</exclude-pattern>
<exclude-pattern>tests/*</exclude-pattern>
<exclude-pattern>vendor/*</exclude-pattern>

<arg value="ps"/>
<arg name="colors"/>
<arg name="parallel" value="100"/>
<arg name="extensions" value="php"/>
<arg name="cache" value=".phpcs.cache"/>

<rule ref="WordPress">
<exclude name="Generic.Commenting.DocComment.MissingShort" />
<exclude name="Squiz.Commenting.FileComment.Missing" />
<exclude name="Squiz.Commenting.ClassComment.Missing" />
<exclude name="Squiz.Commenting.FunctionComment.Missing" />
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment" />
<exclude name="WordPress.Files.FileName" />
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.Found" />
</rule>
<rule ref="WordPress-Extra"/>
<rule ref="WordPress-Docs"/>
</ruleset>
File renamed without changes.
25 changes: 14 additions & 11 deletions MslsSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @copyright Copyright (C) 2011-2024, Dennis Ploetner, re@lloc.de
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 or later
* @wordpress-plugin
* @package mslsselect
*
* Plugin Name: MslsSelect
* Requires Plugins: multisite-language-switcher
Expand Down Expand Up @@ -60,12 +61,12 @@ public function __construct() {
*/
public static function init(): self {
if ( ! is_admin() ) {
add_action( 'wp_enqueue_scripts', [ __CLASS__, 'enqueue_scripts' ] );
add_filter( 'msls_output_get_tags', [ __CLASS__, 'get_tags' ] );
add_filter( 'msls_output_get', [ __CLASS__, 'output_get' ], 10, 3 );
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
add_filter( 'msls_output_get_tags', array( __CLASS__, 'get_tags' ) );
add_filter( 'msls_output_get', array( __CLASS__, 'output_get' ), 10, 3 );
}

return new self;
return new self();
}

/**
Expand All @@ -91,7 +92,7 @@ public static function enqueue_scripts(): void {
*
* @param string $url
* @param object $link
* @param bool $current
* @param bool $current
*
* @return string
*/
Expand All @@ -105,20 +106,22 @@ public static function output_get( string $url, $link, bool $current ): string {
* @return array<string, string>
*/
public static function get_tags(): array {
return [
return array(
'before_item' => '',
'after_item' => '',
'before_output' => '<select class="msls_languages">',
'after_output' => '</select>',
];
);
}

}

// @codeCoverageIgnoreStart
if ( function_exists( 'add_action' ) ) {
add_action( 'plugins_loaded', function () {
MslsSelect::init();
} );
add_action(
'plugins_loaded',
function () {
MslsSelect::init();
}
);
}
// @codeCoverageIgnoreEnd
22 changes: 22 additions & 0 deletions bin/githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

echo ""
echo "phpcbf pre commit hook start"

PHPCBF="vendor/bin/phpcbf"

# check if phpcbf is installed as a composer dependency
if [ -x "$PHPCBF" ]; then
# gets a list of all staged but not deleted php-files
CHANGED_FILES=$(git diff --cached --name-only --diff-filter=ACMRTUXB HEAD | grep '\.php$')

if [ -n "$CHANGED_FILES" ]; then
# runs phpcbf on the changed files
"$PHPCBF" -w $CHANGED_FILES
# adds the changed files to staging again
git add $CHANGED_FILES
fi
fi

echo "phpcbf pre commit hook finish"
echo ""
18 changes: 15 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"name": "lloc/msls-select",
"description": "Transforms the output of the Multisite Language Switcher to an HTML select",
Expand All @@ -18,21 +18,33 @@
"brain/monkey": "2.*",
"phpstan/phpstan": "^1.8",
"szepeviktor/phpstan-wordpress": "^1.1",
"phpstan/extension-installer": "^1.1"
"phpstan/extension-installer": "^1.1",
"wp-coding-standards/wpcs": "^3.0"
},
"scripts": {
"test": "vendor/bin/phpunit",
"coverage": "php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-html coverage",
"analyze": "vendor/bin/phpstan analyze",
"phpstan": "vendor/bin/phpstan analyze",
"git-release": "bin/git-release.sh",
"build": [
"@git-release"
],
"githooks": [
"if [ -e bin/githooks/pre-commit ]; then cp bin/githooks/pre-commit ./.git/hooks/; fi",
"if [ -e .git/hooks/pre-commit ]; then chmod 0755 .git/hooks/pre-commit; fi"
],
"post-install-cmd": [
"@githooks"
],
"post-update-cmd": [
"@githooks"
]
},
"config": {
"allow-plugins": {
"composer/installers": true,
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Contributors: realloc
Donate link: http://www.greenpeace.org/international/
Tags: multilingual, multisite, language, switcher, select
Requires at least: 5.6
Tested up to: 6.7
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 2.3.4
License: GPLv2 or later
Expand Down
Loading