dongsicheng5262 2019-03-14 15:30
浏览 59

WordPress插件函数的命令行运行和刷新输出

A WordPress plugin I have created needs to run a plugin function overnight. I currently run it on a command line using curl http://pathtopluginfunction. I have enabled this by creating an end point using wp-json. It "works", however, this however this is clearly a massive hack.

A big problem is that the output is buffered before being output (according to how http works). This is an issue, because it might cause a buffer overload if the number of items to process is a significant number.

I am looking at wp-cli and there are 3 options which may be appropriate, if at all. These are eval-file, eval, or wp-shell. Also, I'm on both a Windows (dev) and a linux (prod) environment. wp-cli is not a fan of windows.

The function depends heavily on WordPress functions, and functions of the plugin classes. I could rewrite it so it's simply a script without those dependances, but I don't want to do that as it will involve maintaining a separate codebase. Also, it seems wrong.

The biggest issue right now is buffering. The function needs to flush each echo'd output, so as to not cause that overload. A correct command line process would also mean stdout and stderr could be directed appropriately.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料