File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 */
1313
1414class StaticDeployPageCache {
15+ private int $ status_code ;
16+ private string $ status_header ;
17+
1518 public function capture_response (): void {
19+ add_filter (
20+ 'status_header ' ,
21+ [ $ this , 'filter_status_header ' ],
22+ 10 ,
23+ 2
24+ );
1625
1726 $ buffering = ob_start ( [ $ this , 'receive_output ' ] );
1827 if ( $ buffering === false ) {
1928 error_log ( 'Output buffering failed ' );
2029 }
2130 }
2231
32+ /*
33+ * https://developer.wordpress.org/reference/hooks/status_header/
34+ */
35+ public function filter_status_header (
36+ string $ status_header ,
37+ int $ code
38+ ): string {
39+ $ this ->status_code = $ code ;
40+ $ this ->status_header = $ status_header ;
41+ return $ status_header ;
42+ }
43+
2344 /**
2445 * Receives the PHP output, which should be the body
2546 * of an HTTP response, and caches it.
You can’t perform that action at this time.
0 commit comments