Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Static_Files | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| exists | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Detect static files that shadow the SEO package's generated output. |
| 4 | * |
| 5 | * @package automattic/jetpack-seo |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\Jetpack\SEO; |
| 9 | |
| 10 | use Automattic\Jetpack\Constants; |
| 11 | use Automattic\Jetpack\Status\Host; |
| 12 | |
| 13 | /** |
| 14 | * Resolve the public root on hosts that keep WordPress core in a separate directory. |
| 15 | */ |
| 16 | class Static_Files { |
| 17 | |
| 18 | /** |
| 19 | * Check whether a static file takes precedence over WordPress-generated output. |
| 20 | * |
| 21 | * @since 0.10.0 |
| 22 | * @param string $filename Static filename relative to the site's root. |
| 23 | * @return bool Whether the file exists. |
| 24 | */ |
| 25 | public static function exists( $filename ) { |
| 26 | $root = rtrim( Constants::get_constant( 'ABSPATH' ), '/\\' ); |
| 27 | |
| 28 | // Atomic serves the parent directory while keeping managed WordPress core in __wp__. |
| 29 | if ( '__wp__' === basename( $root ) && ( new Host() )->is_atomic_platform() ) { |
| 30 | $root = dirname( $root ); |
| 31 | } |
| 32 | |
| 33 | return file_exists( $root . '/' . $filename ); |
| 34 | } |
| 35 | } |