I was turned down with this question because I get a php error and my question revolves around jquery, but when I take out the JQUERY everything works fine. * Again I'm creating a wordpress plugin. I am trying show and hide options. *
Please any wordpress plugin creator with knowledge on how to implement jquery as a function please help. Please look at the question that was closed to see the script.
Very similar question: Add a jQuery function to admin pages
function accordion() {
echo '<script type="text/javascript">
var $ = jQuery;
jQuery(function ($) {
$.fn.showHide = function (options) {
//default vars for the plugin
var defaults = {
speed: 1000,
easing: '',
changeText: 0,
showText: 'Show',
hideText: 'Hide'
};
var options = $.extend(defaults, options);
$(this).click(function () {
$('.toggleDiv').slideUp(options.speed, options.easing);
var toggleClick = $(this);
var toggleDiv = $(this).attr('rel');
$(toggleDiv).slideToggle(options.speed, options.easing, function() {
// this only fires once the animation is completed
if(options.changeText==1){
$(toggleDiv).is(":visible") ? toggleClick.text(options.hideText) : toggleClick.text(options.showText);
}
});
return false;
});
};
})(jQuery);
</script>';
}
add_action( "admin_footer", "accordion" );