0

One of the plugin is en-queuing a js file in the front-end of my site. I was trying to overwrite it by creating a custom function and hooking it in WP_Footer.

The js added by the plugin file is for the jquery datepicker. I want to modify the datepicker function from my theme file.

Below is how I am hooking the custom function to wp_footer to overwrite the jquery added via plugin from theme with no success:

function wpte_calendar_custom_code()
{ ?>
<script type="text/javascript">
//all of my new jquery code goes here                       
</script>
<?php
add_action( 'wp_footer', 'wpte_calendar_custom_code' );

Also this is how the datepicker script is enqueue in the plugin that I am trying to overwrite:

The plugin datepicker script is inside the public facing class Wp_Travel_Engine_Public of the plugin and the enqueue is done by the function enqueue_scripts like this: wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wp-travel-engine-public.js', array( 'jquery' ), $this->version, false );

Any help on this will be more than appreciable.

Thank you.

  • Show the code that enqueues the plugin's date picker script. – Sally CJ Oct 29 '18 at 14:33
  • This is inside the public facing class Wp_Travel_Engine_Public of the plugin and the enqueue is done by the function enqueue_scripts like this: wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wp-travel-engine-public.js', array( 'jquery' ), $this->version, false ); – saurav.rox Oct 30 '18 at 4:23
  • Did the console show any errors? Did you try lowering the priority (i.e. use a greater number) like 21 as in add_action( 'wp_footer', 'wpte_calendar_custom_code', 21 ); ? Are you overriding just certain code (e.g. functions), or are you actually trying to completely override the whole script? – Sally CJ Oct 30 '18 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.