最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugins - Overwrite js code using WP_Footer

matteradmin9PV0评论

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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far