最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Call javascript function when add_attachment hook fires

programmeradmin0浏览0评论

I want to run a javascript function when the add_attachment hook fires. The following code does not interfere with uploading an image.

add_action('add_attachment', function( $post_ID ) {
    ?>
    <?php
});

When I add script tags and console.log("x"); I get an error message. The error message says "Bei dem Upload ist ein Fehler aufgetreten. Bitte versuche es später nochmal." See picture.

add_action('add_attachment', function( $post_ID ) {
    ?>
    <script type="text/javascript">
        console.log("x");
    </script>
    <?php
});

How can I avoid the error message and validate that my javascript code runs?

发布评论

评论列表(0)

  1. 暂无评论