First things first, there is quite a bit of _doing_it_wrong()
in the script enqueueing.
Don’t override core-bundled scripts
Try removing this hook callback, and see if that fixes things:
function my_scripts_method() {
wp_deregister_script( 'jquery' );
wp_deregister_script( 'jquery ui' );
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js');
wp_register_script( 'jquery ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js');
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery ui' );
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
Core-bundled scripts should never be over-ridden by Plugins or Themes. Replacing the core-bundled version with some other version can and will cause problems.
Enqueue Plugin-bundled scripts properly
These scripts should be enqueued via callback, hooked into an appropriate action:
function myQaptcha_wp_footer() {
if (is_singular() && !is_user_logged_in()) {
$url = get_bloginfo("wpurl");
$outer="<link rel="stylesheet" href="" . $url . '/wp-content/plugins/myqaptcha/jquery/myQaptcha.jquery.css" type="text/css" />'."\n";
$outer.= '<script type="text/javascript" src="' . $url . '/wp-content/plugins/myqaptcha/jquery/jquery.ui.touch.js"></script>'."\n";
$outer.= '<script type="text/javascript">var myQaptchaJqueryPage="' . $url . '/wp-content/plugins/myqaptcha/jquery/myQaptcha.jquery.php";</script>'."\n";
$outer.= '<script type="text/javascript" src="' . $url . '/wp-content/plugins/myqaptcha/jquery/myqaptcha.jquery.js"></script>'."\n";
$outer.= '<script type="text/javascript">jQuery(document).ready(function(){if(jQuery("p:has(\'textarea\')").length>0) jQuery("p:has(\'textarea\')").before(\'<div class="QapTcha"></div>\'); else jQuery("#comment").before(\'<div class="QapTcha"></div>\');jQuery(\'.QapTcha\').QapTcha({disabledSubmit:true,autoRevert:true});});</script>'."\n";
echo $outer;
}
}
Try this instead:
function wpse73486_enqueue_myQaptcha_scripts() {
if ( is_singular() && ! is_user_logged_in() ) {
$url = plugin_dir_url( plugin_basename( __FILE__ ) );
wp_enqueue_style( 'qapcha-jquery', $url . '/jquery/myQaptcha.jquery.css' );
wp_enqueue_script( 'qaptcha-jquery', $url . '/jquery/myqaptcha.jquery.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'jquery-touch-punch' );
// etc.
}
}
add_action( 'wp_enqueue_scripts', 'wpse73486_enqueue_myQaptcha_scripts' );
Move script code to a file, so it can be enqueued
Create a new file, such as qaptcha.script.js
, and put the custom script code inside. If the code requires both jQuery and PHP, put it inside a PHP file, such as qaptcha.script.php
, so that you have access to WordPress functions within the file.
Use updated core-bundled script
WordPress 3.4 now ships with jquery-ui-touch-punch
. You may need to enqueue/use it instead of the Plugin-bundled jquery-ui-touch
library.