@@ -172,7 +172,7 @@ public function content_filter( $content ) {
172
172
*
173
173
* @return string
174
174
*/
175
- function filter_string ( $ pref = '<p id="msls"> ' , $ post = '</p> ' ) {
175
+ public function filter_string ( $ pref = '<p id="msls"> ' , $ post = '</p> ' ) {
176
176
$ obj = MslsOutput::init ();
177
177
$ links = $ obj ->get ( 1 , true , true );
178
178
$ output = __ ( 'This post is also available in %s. ' , 'multisite-language-switcher ' );
@@ -217,31 +217,8 @@ function filter_string( $pref = '<p id="msls">', $post = '</p>' ) {
217
217
*/
218
218
public function block_init () {
219
219
if ( ! $ this ->options ->is_excluded () ) {
220
- $ handle = 'msls-widget-block ' ;
221
- $ callback = [ $ this , 'block_render ' ];
222
-
223
- global $ pagenow ;
224
-
225
- $ toLoad = [ 'wp-blocks ' , 'wp-element ' , 'wp-components ' ];
226
- if ( $ pagenow === 'widgets.php ' ) {
227
- $ toLoad [] = 'wp-edit-widgets ' ;
228
- } else {
229
- $ toLoad [] = 'wp-editor ' ;
230
- }
231
-
232
- wp_register_script (
233
- $ handle ,
234
- self ::plugins_url ( 'js/msls-widget-block.js ' ),
235
- $ toLoad
236
- );
237
-
238
- register_block_type ( 'lloc/msls-widget-block ' , [
239
- 'attributes ' => [ 'title ' => [ 'type ' => 'string ' ] ],
240
- 'editor_script ' => $ handle ,
241
- 'render_callback ' => $ callback ,
242
- ] );
243
-
244
- add_shortcode ( 'sc_msls_widget ' , $ callback );
220
+ register_block_type ( self ::plugin_dir_path ('js/msls-widget-block ' ) );
221
+ add_shortcode ( 'sc_msls_widget ' , [ $ this , 'block_render ' ] );
245
222
246
223
return true ;
247
224
}
@@ -274,15 +251,15 @@ public function custom_enqueue() {
274
251
return false ;
275
252
}
276
253
277
- $ ver = defined ( 'MSLS_PLUGIN_VERSION ' ) ? constant ( 'MSLS_PLUGIN_VERSION ' ) : false ;
278
- $ postfix = defined ( 'SCRIPT_DEBUG ' ) && constant ( 'SCRIPT_DEBUG ' ) ? '' : '.min ' ;
254
+ $ ver = defined ( 'MSLS_PLUGIN_VERSION ' ) ? constant ( 'MSLS_PLUGIN_VERSION ' ) : false ;
255
+ $ folder = defined ( 'SCRIPT_DEBUG ' ) && constant ( 'SCRIPT_DEBUG ' ) ? 'src ' : 'js ' ;
279
256
280
257
wp_enqueue_style ( 'msls-styles ' , self ::plugins_url ( 'css/msls.css ' ), [], $ ver );
281
258
wp_enqueue_style ( 'msls-flags ' , self ::plugins_url ( 'css-flags/css/flag-icon.min.css ' ), [], $ ver );
282
259
283
260
if ( $ this ->options ->activate_autocomplete ) {
284
261
wp_enqueue_script ( 'msls-autocomplete ' ,
285
- self ::plugins_url ( "js /msls{ $ postfix } .js " ),
262
+ self ::plugins_url ( "$ folder /msls.js " ),
286
263
[ 'jquery-ui-autocomplete ' ],
287
264
$ ver );
288
265
0 commit comments