In my Wordpress theme, I have a Theme Options page which is using jQuery UI tabs. These tabs perfectly works in Wordpress versions below 4.4. But they don't seem to work in the versions later than 4.4
It just don't give any error or anything. The other jQuery functions (such as jQuery color-picker, slider..etc.) in the options page are working fine. It's just the tabs which are broken.
In the console I get this message
Uncaught Error: jQuery UI Tabs: Mismatching fragment identifier.
It's from the jQuery.js
file which is included in wp-include/js/jQuery
folder
This is my code...
<div class="ui-tabs">
<ul class="ui-tabs-nav">
foreach ( $this->sections as $section_slug => $section )
echo '<li><a href="#' . $section_slug . '">' . $section . '</a></li>';
</ul>
</div>
<script type="text/javascript">
jQuery(document).ready(function(jQuery) {
var sections = [];';
foreach ( $this->sections as $section_slug => $section )
echo "sections['$section'] = '$section_slug';";
echo 'var wrapped = jQuery(".wrap h3").wrap("<div class=\"ui-tabs-panel\">");
wrapped.each(function() {
jQuery(this).parent().append(jQuery(this).parent().nextUntil("div.ui-tabs-panel"));
});
jQuery(".ui-tabs-panel").each(function(index) {
jQuery(this).attr("id", sections[jQuery(this).children("h3").text()]);
if (index > 0)
jQuery(this).addClass("ui-tabs-hide");
});
jQuery(".ui-tabs").tabs({
fx: { opacity: "toggle", duration: "fast" }
});
jQuery("input[type=text], textarea").each(function() {
if (jQuery(this).val() == jQuery(this).attr("placeholder") || jQuery(this).val() == "")
jQuery(this).css("color", "#999");
});
jQuery("input[type=text], textarea").focus(function() {
if (jQuery(this).val() == jQuery(this).attr("placeholder") || jQuery(this).val() == "") {
jQuery(this).val("");
jQuery(this).css("color", "#000");
}
}).blur(function() {
if (jQuery(this).val() == "" || jQuery(this).val() == jQuery(this).attr("placeholder")) {
jQuery(this).val(jQuery(this).attr("placeholder"));
jQuery(this).css("color", "#999");
}
});
jQuery(".wrap h3, .wrap table").show();
// This will make the "warning" checkbox class really stand out when checked.
// I use it here for the Reset checkbox.
jQuery(".warning").change(function() {
if (jQuery(this).is(":checked"))
jQuery(this).parent().css("background", "#c00").css("color", "#fff").css("fontWeight", "bold");
else
jQuery(this).parent().css("background", "none").css("color", "inherit").css("fontWeight", "normal");
});
// Browser compatibility
if (jQuery.browser.mozilla)
jQuery("form").attr("autocomplete", "off");
});
</script>
What's the reason for this odd behavior ? Is it something in my code ? But it works fine in older versions of WP. Any clue ?