1
1
<?php
2
2
/**
3
3
* MslsPlugin
4
+ *
4
5
* @author Dennis Ploetner <[email protected] >
5
6
* @since 0.9.8
6
7
*/
@@ -38,65 +39,72 @@ public function __construct( MslsOptions $options ) {
38
39
* @return MslsPlugin
39
40
*/
40
41
public static function init () {
41
- $ obj = new self ( msls_options () );
42
+ $ obj = new self ( msls_options () );
42
43
43
- add_action ( 'plugins_loaded ' , [ $ obj , 'init_i18n_support ' ] );
44
+ add_action ( 'plugins_loaded ' , array ( $ obj , 'init_i18n_support ' ) );
44
45
45
- register_activation_hook ( self ::file (), [ $ obj , 'activate ' ] );
46
+ register_activation_hook ( self ::file (), array ( $ obj , 'activate ' ) );
46
47
47
48
if ( function_exists ( 'is_multisite ' ) && is_multisite () ) {
48
- add_filter ( 'msls_get_output ' , [ __CLASS__ , 'get_output ' ] );
49
+ add_filter ( 'msls_get_output ' , array ( __CLASS__ , 'get_output ' ) );
49
50
50
- add_action ( 'widgets_init ' , [ $ obj , 'init_widget ' ] );
51
- add_filter ( 'the_content ' , [ $ obj , 'content_filter ' ] );
51
+ add_action ( 'widgets_init ' , array ( $ obj , 'init_widget ' ) );
52
+ add_filter ( 'the_content ' , array ( $ obj , 'content_filter ' ) );
52
53
53
- add_action ( 'wp_head ' , [ __CLASS__ , 'print_alternate_links ' ] );
54
+ add_action ( 'wp_head ' , array ( __CLASS__ , 'print_alternate_links ' ) );
54
55
55
56
if ( function_exists ( 'register_block_type ' ) ) {
56
- add_action ( 'init ' , [ $ obj , 'block_init ' ] );
57
+ add_action ( 'init ' , array ( $ obj , 'block_init ' ) );
57
58
}
58
59
59
- add_action ( 'init ' , [ $ obj , 'admin_bar_init ' ] );
60
- add_action ( 'admin_enqueue_scripts ' , [ $ obj , 'custom_enqueue ' ] );
61
- add_action ( 'wp_enqueue_scripts ' , [ $ obj , 'custom_enqueue ' ] );
60
+ add_action ( 'init ' , array ( $ obj , 'admin_bar_init ' ) );
61
+ add_action ( 'admin_enqueue_scripts ' , array ( $ obj , 'custom_enqueue ' ) );
62
+ add_action ( 'wp_enqueue_scripts ' , array ( $ obj , 'custom_enqueue ' ) );
62
63
63
64
\lloc \Msls \ContentImport \Service::instance ()->register ();
64
65
65
66
if ( is_admin () ) {
66
- add_action ( 'admin_menu ' , [ MslsAdmin::class, 'init ' ] );
67
- add_action ( 'load-post.php ' , [ MslsMetaBox::class, 'init ' ] );
68
- add_action ( 'load-post-new.php ' , [ MslsMetaBox::class, 'init ' ] );
69
- add_action ( 'load-edit.php ' , [ MslsCustomColumn::class, 'init ' ] );
70
- add_action ( 'load-edit.php ' , [ MslsCustomFilter::class, 'init ' ] );
67
+ add_action ( 'admin_menu ' , array ( MslsAdmin::class, 'init ' ) );
68
+ add_action ( 'load-post.php ' , array ( MslsMetaBox::class, 'init ' ) );
69
+ add_action ( 'load-post-new.php ' , array ( MslsMetaBox::class, 'init ' ) );
70
+ add_action ( 'load-edit.php ' , array ( MslsCustomColumn::class, 'init ' ) );
71
+ add_action ( 'load-edit.php ' , array ( MslsCustomFilter::class, 'init ' ) );
71
72
72
- add_action ( 'load-edit-tags.php ' , [ MslsCustomColumnTaxonomy::class, 'init ' ] );
73
- add_action ( 'load-edit-tags.php ' , [ MslsPostTag::class, 'init ' ] );
74
- add_action ( 'load-term.php ' , [ MslsPostTag::class, 'init ' ] );
73
+ add_action ( 'load-edit-tags.php ' , array ( MslsCustomColumnTaxonomy::class, 'init ' ) );
74
+ add_action ( 'load-edit-tags.php ' , array ( MslsPostTag::class, 'init ' ) );
75
+ add_action ( 'load-term.php ' , array ( MslsPostTag::class, 'init ' ) );
75
76
76
77
if ( filter_has_var ( INPUT_POST , 'action ' ) ) {
77
78
$ action = filter_input ( INPUT_POST , 'action ' , FILTER_SANITIZE_FULL_SPECIAL_CHARS );
78
79
79
80
if ( 'add-tag ' === $ action ) {
80
- add_action ( 'admin_init ' , [ MslsPostTag::class, 'init ' ] );
81
+ add_action ( 'admin_init ' , array ( MslsPostTag::class, 'init ' ) );
81
82
} elseif ( 'inline-save ' === $ action ) {
82
- add_action ( 'admin_init ' , [ MslsCustomColumn::class, 'init ' ] );
83
+ add_action ( 'admin_init ' , array ( MslsCustomColumn::class, 'init ' ) );
83
84
} elseif ( 'inline-save-tax ' === $ action ) {
84
- add_action ( 'admin_init ' , [ MslsCustomColumnTaxonomy::class, 'init ' ] );
85
+ add_action ( 'admin_init ' , array ( MslsCustomColumnTaxonomy::class, 'init ' ) );
85
86
}
86
87
}
87
88
88
- add_action ( 'wp_ajax_suggest_posts ' , [ MslsMetaBox::class, 'suggest ' ] );
89
- add_action ( 'wp_ajax_suggest_terms ' , [ MslsPostTag::class, 'suggest ' ] );
89
+ add_action ( 'wp_ajax_suggest_posts ' , array ( MslsMetaBox::class, 'suggest ' ) );
90
+ add_action ( 'wp_ajax_suggest_terms ' , array ( MslsPostTag::class, 'suggest ' ) );
90
91
}
91
92
} else {
92
- add_action ( 'admin_notices ' , function () {
93
- $ href = 'https://wordpress.org/support/article/create-a-network/ ' ;
94
- $ 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. ' ,
95
- 'multisite-language-switcher ' ),
96
- $ href );
97
-
98
- self ::message_handler ( $ msg );
99
- } );
93
+ add_action (
94
+ 'admin_notices ' ,
95
+ function () {
96
+ $ href = 'https://wordpress.org/support/article/create-a-network/ ' ;
97
+ $ msg = sprintf (
98
+ __ (
99
+ '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. ' ,
100
+ 'multisite-language-switcher '
101
+ ),
102
+ $ href
103
+ );
104
+
105
+ self ::message_handler ( $ msg );
106
+ }
107
+ );
100
108
}
101
109
102
110
return $ obj ;
@@ -129,12 +137,22 @@ public static function update_adminbar( \WP_Admin_Bar $wp_admin_bar ): void {
129
137
foreach ( $ blog_collection ->get_plugin_active_blogs () as $ blog ) {
130
138
$ title = $ blog ->get_blavatar () . $ blog ->get_title ( $ icon_type );
131
139
132
- $ wp_admin_bar ->add_node ( [ 'id ' => 'blog- ' . $ blog ->userblog_id , 'title ' => $ title ] );
140
+ $ wp_admin_bar ->add_node (
141
+ array (
142
+ 'id ' => 'blog- ' . $ blog ->userblog_id ,
143
+ 'title ' => $ title ,
144
+ )
145
+ );
133
146
}
134
147
135
148
$ blog = $ blog_collection ->get_current_blog ();
136
149
if ( is_object ( $ blog ) && method_exists ( $ blog , 'get_title ' ) ) {
137
- $ wp_admin_bar ->add_node ( [ 'id ' => 'site-name ' , 'title ' => $ blog ->get_title ( $ icon_type ) ] );
150
+ $ wp_admin_bar ->add_node (
151
+ array (
152
+ 'id ' => 'site-name ' ,
153
+ 'title ' => $ blog ->get_title ( $ icon_type ),
154
+ )
155
+ );
138
156
}
139
157
}
140
158
@@ -195,7 +213,7 @@ public function filter_string( $pref = '<p id="msls">', $post = '</p>' ) {
195
213
$ output = sprintf (
196
214
$ output ,
197
215
sprintf (
198
- __ ( '%s and %s ' , 'multisite-language-switcher ' ),
216
+ __ ( '%1$ s and %2$ s ' , 'multisite-language-switcher ' ),
199
217
implode ( ', ' , $ links ),
200
218
$ last
201
219
)
@@ -213,12 +231,13 @@ public function filter_string( $pref = '<p id="msls">', $post = '</p>' ) {
213
231
214
232
/**
215
233
* Register block and shortcode.
234
+ *
216
235
* @return bool
217
236
*/
218
237
public function block_init () {
219
238
if ( ! $ this ->options ->is_excluded () ) {
220
- register_block_type ( self ::plugin_dir_path ('js/msls-widget-block ' ) );
221
- add_shortcode ( 'sc_msls_widget ' , [ $ this , 'block_render ' ] );
239
+ register_block_type ( self ::plugin_dir_path ( 'js/msls-widget-block ' ) );
240
+ add_shortcode ( 'sc_msls_widget ' , array ( $ this , 'block_render ' ) );
222
241
223
242
return true ;
224
243
}
@@ -231,7 +250,7 @@ public function block_init() {
231
250
*/
232
251
public function admin_bar_init () {
233
252
if ( is_admin_bar_showing () && is_super_admin () ) {
234
- add_action ( 'admin_bar_menu ' , [ __CLASS__ , 'update_adminbar ' ] , 999 );
253
+ add_action ( 'admin_bar_menu ' , array ( __CLASS__ , 'update_adminbar ' ) , 999 );
235
254
236
255
return true ;
237
256
}
@@ -254,14 +273,11 @@ public function custom_enqueue() {
254
273
$ ver = defined ( 'MSLS_PLUGIN_VERSION ' ) ? constant ( 'MSLS_PLUGIN_VERSION ' ) : false ;
255
274
$ folder = defined ( 'SCRIPT_DEBUG ' ) && constant ( 'SCRIPT_DEBUG ' ) ? 'src ' : 'js ' ;
256
275
257
- wp_enqueue_style ( 'msls-styles ' , self ::plugins_url ( 'css/msls.css ' ), [] , $ ver );
258
- wp_enqueue_style ( 'msls-flags ' , self ::plugins_url ( 'css-flags/css/flag-icon.min.css ' ), [] , $ ver );
276
+ wp_enqueue_style ( 'msls-styles ' , self ::plugins_url ( 'css/msls.css ' ), array () , $ ver );
277
+ wp_enqueue_style ( 'msls-flags ' , self ::plugins_url ( 'css-flags/css/flag-icon.min.css ' ), array () , $ ver );
259
278
260
279
if ( $ this ->options ->activate_autocomplete ) {
261
- wp_enqueue_script ( 'msls-autocomplete ' ,
262
- self ::plugins_url ( "$ folder/msls.js " ),
263
- [ 'jquery-ui-autocomplete ' ],
264
- $ ver );
280
+ wp_enqueue_script ( 'msls-autocomplete ' , self ::plugins_url ( "$ folder/msls.js " ), array ( 'jquery-ui-autocomplete ' ), $ ver );
265
281
266
282
return true ;
267
283
}
@@ -319,6 +335,7 @@ public static function path(): string {
319
335
*
320
336
* The widget will only be registered if the current blog is not
321
337
* excluded in the configuration of the plugin.
338
+ *
322
339
* @return boolean
323
340
*/
324
341
public function init_widget () {
@@ -384,7 +401,7 @@ public static function message_handler( $message, $css_class = 'error' ) {
384
401
* Activate plugin
385
402
*/
386
403
public static function activate () {
387
- register_uninstall_hook ( self ::file (), [ __CLASS__ , 'uninstall ' ] );
404
+ register_uninstall_hook ( self ::file (), array ( __CLASS__ , 'uninstall ' ) );
388
405
}
389
406
390
407
/**
@@ -452,7 +469,7 @@ public static function cleanup() {
452
469
* @return array
453
470
*/
454
471
public static function get_superglobals ( array $ list ) {
455
- $ arr = [] ;
472
+ $ arr = array () ;
456
473
457
474
foreach ( $ list as $ var ) {
458
475
$ arr [ $ var ] = '' ;
@@ -466,5 +483,4 @@ public static function get_superglobals( array $list ) {
466
483
467
484
return $ arr ;
468
485
}
469
-
470
486
}
0 commit comments