【问题标题】:Is there a way to manually trigger WordPress' heartbeat有没有办法手动触发 WordPress 的心跳
【发布时间】:2020-12-03 13:33:45
【问题描述】:

我写了一些通过heartbeat-send JS 事件连接到 WordPress 心跳的东西。
但是,为了测试事情,我会坐下来等待。

我尝试从控制台运行jQuery(document).trigger("heartbeat-send");,但没有成功。
我不确定如何随时触发心跳,或者是否有可能:)

【问题讨论】:

    标签: wordpress wordpress-admin


    【解决方案1】:

    请参考下面的链接对你有帮助

    https://developer.wordpress.org/plugins/javascript/heartbeat-api/

    jQuery(document).on('heartbeat-tick', function(event, data) {
        // Check for our data, and use it.
        if (!data.myplugin_customfield_hashed) {
            return;
        }
        alert('The hash is ' + data.myplugin_customfield_hashed);
    });
    

    【讨论】:

    • tick 不是接收事件吗?您如何强制心跳发生在 WordPress 设置的时间间隔之外?一个蹩脚的例子是:我想在单击按钮时触发心跳。你会怎么做?有可能吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-02
    • 1970-01-01
    • 1970-01-01
    • 2010-11-21
    • 2011-01-30
    • 1970-01-01
    相关资源
    最近更新 更多