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
3536
3637/**
3738 * MslsMenu Class
39+ *
3840 * @package mslsmenu
3941 */
4042final 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
237236if ( 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
0 commit comments