• Hello everyone,

    I am very new to WordPress plugin development and am developing a simple plugin to practice and get more involved with the wordpress API. At the moment, I am just trying to use jQuery to prompt an alert box when the publish button is clicked and am having issues getting it to work properly, and am not sure what I have done wrong.

    <?php
    /**
     * @package Are Your Sure?
     * @author Drew Douglass
     * @version 1.0
     */
    /*
    Plugin Name: Are You Sure?
    Plugin URI: http://dev-tips.com
    Description: Basic plugin
    Author: Drew Douglass
    Version: 1.0
    Author URI: http://dev-tips.com
    */
    if(!function_exists('are_you_sure_init')){
    	function are_you_sure_init(){
    		$ays_js = wp_enqueue_script('aysjquery','/wp-content/plugins/aysjquery.js', array('jquery'), '1.2.6');
    		return $ays_js;
    	}
    	are_you_sure_init();
    }
    
    ?>

    Above is the plugin php script located in the plugin folder.

    Below is the jQuery script linked to in the are_you_sure_init function:

    $(function(){
    	$('#publish').click(function(){
    		alert('Hello!');
    		return false;
    	});
    });

    In firebug I can see the script is indeed being called after jQuery is, but there is no alert and the publish button continues to run instead of returning false.

    Can anyone point me in the right direction with a link or suggestion as to what I am doing incorrectly? Do you think it could be another Javascript code used by wordpress interfering with mine? I am not looking for anyone to code for me, just for help on where to look to solve my issue.

    Best Regards,

    Drew

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘New plugin developer, jQuery script issue.’ is closed to new replies.