| Conditions | 5 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 5 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | private function isRestRequest() { |
||
|
1 ignored issue
–
show
|
|||
| 18 | |||
| 19 | if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { |
||
| 20 | return true; |
||
| 21 | } |
||
| 22 | |||
| 23 | // This is dirty, but no better way to detect before parse_request. |
||
| 24 | if ( ! empty( $_SERVER['REQUEST_URI'] ) && 0 !== stripos( $_SERVER['REQUEST_URI'], rest_get_url_prefix() ) ) { |
||
| 25 | return true; |
||
| 26 | } |
||
| 27 | |||
| 28 | return false; |
||
| 29 | } |
||
| 59 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: