在WordPress中重新声明jquery插件函数

Redeclare jquery plugin function in WordPress

本文关键字:声明 jquery 插件 函数 WordPress 新声明      更新时间:2023-09-26

在Wordpress v4.0文件/wp-includes/js/wplink.js的第200行中,我想通过Wordpress插件将我自己的js排队,并重新定义函数htmlUpdate来修改它的功能。正确的方法是什么?

附言:我可以满足于询问脚本等。只需要帮助如何用我自己的插件覆盖功能。

htmlUpdate: function() {
//... blah blah
}

您可以这样尝试:

add_action( 'admin_footer-post-new.php', 'my_custom_method', 9999 );
add_action( 'admin_footer-post.php',     'my_custom_method', 9999 );
function my_custom_method() {
    ?>
    <script type="text/javascript">
        ( function( $ ) {
            if ( typeof wpLink == 'undefined' )
                return;
            // Override the function
            wpLink.htmlUpdate= function () { 
                //... blah blah
            };
        } )( jQuery );
    </script>
   <?php
}

希望这就是你想要的。。