why am I getting two js alert instead of one per plugin function calls
-
I have to make jquery connection to wordpress. I have two plugin created and installed to test jquery wordpress workability
when I run the first_plugin
am supposed to get only one alert “first plugin working” which corresponds to first_plugin function
Instead am getting 2 alertseg first plugin working
second plugin working and vice versafirst_plugin code
add_action('wp_enqueue_scripts','first_plugin'); function first_plugin() { // JavaScript wp_enqueue_script( 'scriptjs1', plugins_url( '/script1.js', __FILE__ ),array('jquery')); // Pass ajax_url to script.js //wp_localize_script( 'script-js', 'plugin_ajax_object', //array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); }
script1.js
jQuery(document).ready(function($){ alert('first plugin working'); });
second_plugi code
add_action('wp_enqueue_scripts','second_plugin'); function second_plugin() { // JavaScript wp_enqueue_script( 'scriptjs2', plugins_url( '/script2.js', __FILE__ ),array('jquery')); }
script2.js
jQuery(document).ready(function($){ alert('second plugin working'); });
My question is this: Is it how this wp_enqueue_scripts() function work by alerting content in another second_plugin into first_plugin and vice versa. Thanks
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘why am I getting two js alert instead of one per plugin function calls’ is closed to new replies.