Skip to content

Commit 4c9be24

Browse files
committed
Adjusted build
1 parent 1003b37 commit 4c9be24

6 files changed

Lines changed: 42 additions & 40 deletions

File tree

.distignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ coverage.xml
1212
.gitignore
1313
.phpunit.result.cache
1414
.scrutinizer.yml
15-
Changelog.md
16-
composer.json
1715
composer.lock
1816
mslsmenu.zip
1917
package.json
2018
package-lock.json
2119
phpdoc.xml
22-
phpstan.neon
20+
.phpstan.neon.dist
21+
.phpcs.cache
22+
.phpcs.xml.dist
2323
phpunit.xml
2424
README.md

.phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
<arg name="cache" value=".phpcs.cache"/>
1414

1515
<rule ref="WordPress">
16-
<!-- PSR4 -->
1716
<exclude name="Generic.Commenting.DocComment.MissingShort" />
1817
<exclude name="Squiz.Commenting.FileComment.Missing" />
1918
<exclude name="Squiz.Commenting.ClassComment.Missing" />
2019
<exclude name="Squiz.Commenting.FunctionComment.Missing" />
2120
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment" />
2221
<exclude name="WordPress.Files.FileName" />
22+
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.Found" />
2323
</rule>
2424
<rule ref="WordPress-Extra"/>
2525
<rule ref="WordPress-Docs"/>
File renamed without changes.

MslsMenu.php

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* @copyright Copyright (C) 2011-2022, Dennis Ploetner, re@lloc.de
66
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 or later
77
* @wordpress-plugin
8+
* @package mslsmenu
89
*
910
* Plugin Name: MslsMenu
1011
* Requires Plugins: multisite-language-switcher
@@ -35,6 +36,7 @@
3536

3637
/**
3738
* MslsMenu Class
39+
*
3840
* @package mslsmenu
3941
*/
4042
final class MslsMenu {
@@ -56,8 +58,6 @@ final class MslsMenu {
5658
*/
5759
public function __construct( $options ) {
5860
$this->options = $options;
59-
60-
load_plugin_textdomain( 'mslsmenu', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
6161
}
6262

6363
/**
@@ -71,21 +71,21 @@ public static function init( $options ): MslsMenu {
7171
$obj = new self( $options );
7272

7373
if ( ! is_null( $options ) ) {
74-
add_filter( 'wp_nav_menu_items', [ $obj, 'nav_item' ], 10, 2 );
75-
add_action( 'msls_admin_register', [ $obj, 'admin_register' ] );
74+
add_filter( 'wp_nav_menu_items', array( $obj, 'nav_item' ), 10, 2 );
75+
add_action( 'msls_admin_register', array( $obj, 'admin_register' ) );
7676
}
7777

7878
return $obj;
7979
}
8080

81-
private function get_msls_output(): lloc\Msls\MslsOutput{
81+
private function get_msls_output(): lloc\Msls\MslsOutput {
8282
return function_exists( 'msls_output' ) ? msls_output() : lloc\Msls\MslsOutput::init();
8383
}
8484

8585
/**
8686
* Callback for wp_nav_menu_items
8787
*
88-
* @param string $items
88+
* @param string $items
8989
* @param \stdClass $args
9090
*
9191
* @return string
@@ -94,7 +94,7 @@ public function nav_item( string $items, \stdClass $args ): string {
9494
$menu_locations = $this->options->mslsmenu_theme_location ?? '';
9595
$theme_location = $args->theme_location ?? '';
9696

97-
if ( is_array( $menu_locations ) && in_array( $theme_location, $menu_locations ) ) {
97+
if ( is_array( $menu_locations ) && in_array( $theme_location, $menu_locations, true ) ) {
9898
$menu = '';
9999

100100
$obj = $this->get_msls_output();
@@ -118,31 +118,31 @@ public function admin_register( string $page ) {
118118

119119
$this->page = $page;
120120

121-
add_settings_section( self::SID, $label, [ $this, 'add_settings' ], $page );
121+
add_settings_section( self::SID, $label, array( $this, 'add_settings' ), $page );
122122
}
123123

124124
/**
125125
* Callback for add_settings_section in admin_register
126126
*/
127127
public function add_settings(): void {
128-
$args = [ 'msls_admin' => lloc\Msls\MslsAdmin::init() ];
128+
$args = array( 'msls_admin' => lloc\Msls\MslsAdmin::init() );
129129

130130
$label = __( 'Theme Location', 'mslsmenu' );
131-
$callback = [ $this, 'theme_location' ];
131+
$callback = array( $this, 'theme_location' );
132132
add_settings_field( 'mslsmenu_theme_location', $label, $callback, $this->page, self::SID, $args );
133133

134134
$label = __( 'Display', 'mslsmenu' );
135-
$callback = [ $this, 'display' ];
135+
$callback = array( $this, 'display' );
136136
add_settings_field( 'mslsmenu_display', $label, $callback, $this->page, self::SID, $args );
137137

138-
$fields = [
138+
$fields = array(
139139
'mslsmenu_before_output' => __( 'Text/HTML before the list', 'mslsmenu' ),
140140
'mslsmenu_after_output' => __( 'Text/HTML after the list', 'mslsmenu' ),
141141
'mslsmenu_before_item' => __( 'Text/HTML before each item', 'mslsmenu' ),
142142
'mslsmenu_after_item' => __( 'Text/HTML after each item', 'mslsmenu' ),
143-
];
143+
);
144144

145-
$callback = [ $this, 'input' ];
145+
$callback = array( $this, 'input' );
146146
foreach ( $fields as $id => $label ) {
147147
$args['mslsmenu_input'] = $id;
148148
add_settings_field( $id, $label, $callback, $this->page, self::SID, $args );
@@ -157,26 +157,26 @@ public function add_settings(): void {
157157
public function theme_location( array $args ) {
158158
$menu_locations = get_nav_menu_locations();
159159
$theme_locations = $this->options->mslsmenu_theme_location ?? '';
160-
$options = [
161-
sprintf( '<option value="" %s>%s</option>', $this->selected( '', $theme_locations ), esc_html__( '-- empty --', 'mslsmenu' ) )
162-
];
160+
$options = array(
161+
sprintf( '<option value="" %s>%s</option>', $this->selected( '', $theme_locations ), esc_html__( '-- empty --', 'mslsmenu' ) ),
162+
);
163163

164164
foreach ( array_keys( $menu_locations ) as $value ) {
165165
$options[] = sprintf( '<option value="%1$s" %2$s>%1$s</option>', esc_attr( $value ), $this->selected( $value, $theme_locations ) );
166166
}
167167

168168
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
169-
printf( '<select id="%1$s" name="msls[%1$s][]" multiple="multiple">%2$s</select>', 'mslsmenu_theme_location', implode( '', $options ) );
169+
printf( '<select id="%1$s" name="msls[%1$s][]" multiple="multiple">%2$s</select>', 'mslsmenu_theme_location', implode( '', $options ) );
170170
}
171171

172172
/**
173173
* @param string $needle
174-
* @param mixed $locations
174+
* @param mixed $locations
175175
*
176176
* @return string
177177
*/
178178
protected function selected( string $needle, $locations ): string {
179-
return is_array( $locations ) ? selected( true, in_array( $needle, $locations ), false ) : '';
179+
return is_array( $locations ) ? selected( true, in_array( $needle, $locations, true ), false ) : '';
180180
}
181181

182182
/**
@@ -188,9 +188,9 @@ public function display( array $args ) {
188188
$types = lloc\Msls\MslsLink::get_types_description();
189189
$display = $this->options->mslsmenu_display ?? '0';
190190

191-
/**
192-
* Backward compatibility
193-
*/
191+
/**
192+
* Backward compatibility
193+
*/
194194
if ( ! class_exists( lloc\Msls\Component\Input\Select::class ) ) {
195195
// @codeCoverageIgnoreStart
196196

@@ -211,14 +211,14 @@ public function display( array $args ) {
211211
* @param array $args
212212
*/
213213
public function input( array $args ) {
214-
/**
215-
* Backward compatibility
216-
*/
214+
/**
215+
* Backward compatibility
216+
*/
217217
if ( ! class_exists( 'lloc\Msls\Component\Input\Text' ) ) {
218218
// @codeCoverageIgnoreStart
219219

220220
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
221-
echo $args['msls_admin']->render_input( $args['mslsmenu_input'] );
221+
echo $args['msls_admin']->render_input( $args['mslsmenu_input'] );
222222

223223
return;
224224
// @codeCoverageIgnoreEnd
@@ -228,16 +228,18 @@ public function input( array $args ) {
228228
$value = $this->options->$key ?? '';
229229

230230
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
231-
echo ( new lloc\Msls\Component\Input\Text( $key, $value ) )->render();
231+
echo ( new lloc\Msls\Component\Input\Text( $key, $value ) )->render();
232232
}
233-
234233
}
235234

236235
// @codeCoverageIgnoreStart
237236
if ( function_exists( 'add_action' ) ) {
238-
add_action( 'plugins_loaded', function () {
239-
$options = class_exists( lloc\Msls\MslsOptions::class ) ? lloc\Msls\MslsOptions::instance() : null;
240-
MslsMenu::init( $options );
241-
} );
237+
add_action(
238+
'plugins_loaded',
239+
function () {
240+
$options = class_exists( lloc\Msls\MslsOptions::class ) ? lloc\Msls\MslsOptions::instance() : null;
241+
MslsMenu::init( $options );
242+
}
243+
);
242244
}
243-
// @codeCoverageIgnoreEnd
245+
// @codeCoverageIgnoreEnd

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"scripts": {
2323
"test": "vendor/bin/pest",
2424
"coverage": "php -d xdebug.mode=coverage vendor/bin/pest --coverage",
25-
"analyze": "vendor/bin/phpstan analyze",
25+
"phpstan": "vendor/bin/phpstan analyze",
2626
"git-release": "bin/git-release.sh",
2727
"build": [
2828
"@git-release"

languages/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php header( 'location: http://' . filter_input( INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_URL ) ); ?>
1+
<?php header( 'location: http://' . filter_input( INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_URL ) );

0 commit comments

Comments
 (0)