Skip to content
This repository was archived by the owner on Apr 7, 2024. It is now read-only.

Commit 1640325

Browse files
committed
debugged missing language switcher in post edit page / bug VaLeXaR#177
- checks if toolbar is loaded and deferres adding if needed
1 parent 5c1556d commit 1640325

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

includes/admin/class-wpm-admin-assets.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,20 @@ public function add_language_switcher() {
191191

192192
$script = "
193193
(function( $ ) {
194-
$(window).on('pageshow',function(){
194+
$(window).on('pageshow', function(){
195195
if ($('#wpm-language-switcher').length === 0) {
196196
var language_switcher = wp.template( 'wpm-ls-customizer' );
197-
$('.edit-post-header-toolbar').prepend(language_switcher);
197+
198+
var wpm_add_language_switcher_deferred = function() {
199+
var toolbar = $('.edit-post-header-toolbar');
200+
if(toolbar.length) {
201+
toolbar.prepend(language_switcher);
202+
} else {
203+
window.setTimeout(wpm_add_language_switcher_deferred, 100);
204+
}
205+
}
206+
207+
wpm_add_language_switcher_deferred();
198208
}
199209
});
200210

0 commit comments

Comments
 (0)