@@ -172,7 +172,7 @@ public function content_filter( $content ) {
172172 *
173173 * @return string
174174 */
175- function filter_string ( $ pref = '<p id="msls"> ' , $ post = '</p> ' ) {
175+ public function filter_string ( $ pref = '<p id="msls"> ' , $ post = '</p> ' ) {
176176 $ obj = MslsOutput::init ();
177177 $ links = $ obj ->get ( 1 , true , true );
178178 $ output = __ ( 'This post is also available in %s. ' , 'multisite-language-switcher ' );
@@ -217,31 +217,8 @@ function filter_string( $pref = '<p id="msls">', $post = '</p>' ) {
217217 */
218218 public function block_init () {
219219 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 ' ] );
245222
246223 return true ;
247224 }
@@ -274,15 +251,15 @@ public function custom_enqueue() {
274251 return false ;
275252 }
276253
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 ' ;
279256
280257 wp_enqueue_style ( 'msls-styles ' , self ::plugins_url ( 'css/msls.css ' ), [], $ ver );
281258 wp_enqueue_style ( 'msls-flags ' , self ::plugins_url ( 'css-flags/css/flag-icon.min.css ' ), [], $ ver );
282259
283260 if ( $ this ->options ->activate_autocomplete ) {
284261 wp_enqueue_script ( 'msls-autocomplete ' ,
285- self ::plugins_url ( "js /msls{ $ postfix } .js " ),
262+ self ::plugins_url ( "$ folder /msls.js " ),
286263 [ 'jquery-ui-autocomplete ' ],
287264 $ ver );
288265
0 commit comments