File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,17 @@ function perflab_server_timing() {
3232
3333 if ( null === $ server_timing ) {
3434 $ server_timing = new Perflab_Server_Timing ();
35+
36+ /*
37+ * Do not add the hook for Server-Timing header output if it is entirely disabled.
38+ * While the constant checks on top of the file prevent this from happening by default, external code could
39+ * still call the `perflab_server_timing()` function. It needs to be ensured that such calls do not result in
40+ * fatal errors, but they should at least not lead to the header being output.
41+ */
42+ if ( defined ( 'PERFLAB_DISABLE_SERVER_TIMING ' ) && PERFLAB_DISABLE_SERVER_TIMING ) {
43+ return $ server_timing ;
44+ }
45+
3546 add_filter ( 'template_include ' , array ( $ server_timing , 'on_template_include ' ), PHP_INT_MAX );
3647 }
3748
You can’t perform that action at this time.
0 commit comments