| 1 |
<?php |
| 2 |
/** |
| 3 |
* Detection pipeline. |
| 4 |
* |
| 5 |
* Thin entry point that delegates to the Consolidator (the aggregate-and-replace |
| 6 |
* engine). Kept as a stable seam so the output buffer and any add-ons don't need |
| 7 |
* to know about the consolidation internals. |
| 8 |
* |
| 9 |
* @package EasyFonts |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace EasyFonts\Detect; |
| 13 |
|
| 14 |
defined( 'ABSPATH' ) || exit; |
| 15 |
|
| 16 |
/** |
| 17 |
* Coordinates font detection + local hosting for a document. |
| 18 |
*/ |
| 19 |
class Pipeline { |
| 20 |
|
| 21 |
/** |
| 22 |
* Process a document: detect every web-font source, host them locally as a |
| 23 |
* single consolidated stylesheet, and return the rewritten HTML. |
| 24 |
* |
| 25 |
* @param string $html Full HTML. |
| 26 |
* @param bool $force Force a full pass (probe mode). |
| 27 |
* @param array<string,bool> $scope_out Confirmed loaded-but-unused families on this route (lowercased => true). |
| 28 |
* @param bool $measured Route has beacon data (enables scoping). |
| 29 |
* @return string |
| 30 |
*/ |
| 31 |
public function process( string $html, bool $force = false, array $scope_out = array(), bool $measured = false ): string { |
| 32 |
/** |
| 33 |
* Filter the consolidator instance, allowing advanced replacement. |
| 34 |
* |
| 35 |
* @param Consolidator $consolidator |
| 36 |
*/ |
| 37 |
$consolidator = apply_filters( 'easyfonts_consolidator', new Consolidator() ); |
| 38 |
|
| 39 |
if ( method_exists( $consolidator, 'set_page_scope' ) ) { |
| 40 |
$consolidator->set_page_scope( $scope_out, $measured ); |
| 41 |
} |
| 42 |
|
| 43 |
return $consolidator->run( $html, $force ); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Variants hosted during the most recent run (for fallbacks + usage). |
| 48 |
* |
| 49 |
* @return array<int,array{family:string,weight:string,style:string}> |
| 50 |
*/ |
| 51 |
public static function touched(): array { |
| 52 |
return Consolidator::touched(); |
| 53 |
} |
| 54 |
} |
| 55 |
|