plugins - Overwrite js code using WP_Footer

admin2025-06-06  10

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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749222048a317385.html

最新回复(0)