开发者

How can I intercept and modify HTTP responses with a WordPress plugin?

开发者 https://www.devze.com 2023-03-18 08:35 出处:网络
I\'d like to know how to alter an HTTP response within a WordPress plugin, so I can make changes without digging into the WordPress codebase. I have some idea of a technique that might work but I don\

I'd like to know how to alter an HTTP response within a WordPress plugin, so I can make changes without digging into the WordPress codebase. I have some idea of a technique that might work but I don't know the particulars.

  • Add a function to a hook that happens early on during the processing of a request, and tell PHP to buffer (and not send) data that'开发者_JS百科s written to the response stream until it's been flushed.
  • Add a function to a hook that happens toward the end of the processing of a request, that gets the buffered response, modifies it, and sends it.
0

精彩评论

暂无评论...
验证码 换一张
取 消