WordPress中的Redeclare jquery插件功能

时间:2014-10-09 08:44:25

标签: javascript jquery wordpress wordpress-plugin

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

PS:我很喜欢使用enqueing脚本等。只需要帮助解决如何使用我自己的插件覆盖功能。

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

1 个答案:

答案 0 :(得分:0)

您可以尝试这样:

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
}

希望这就是你要找的......