| 1 |
<?php |
| 2 |
|
| 3 |
namespace BitCode\BitForm\Core\Util\Translation; |
| 4 |
|
| 5 |
/** |
| 6 |
* Presence checks for the built-in providers, in one small file the manager can |
| 7 |
* load instead of every provider class. Each provider's isAvailable() delegates |
| 8 |
* here, so a rule has exactly one home. |
| 9 |
* |
| 10 |
* `::class` in the match arms is a compile-time string and does not autoload. |
| 11 |
*/ |
| 12 |
final class ProviderProbe |
| 13 |
{ |
| 14 |
/** |
| 15 |
* @param mixed $class |
| 16 |
* |
| 17 |
* @return bool|null null when $class is not a built-in provider |
| 18 |
*/ |
| 19 |
public static function isActive($class) |
| 20 |
{ |
| 21 |
switch ($class) { |
| 22 |
case Provider\WpmlProvider::class: |
| 23 |
return defined('ICL_SITEPRESS_VERSION'); |
| 24 |
|
| 25 |
case Provider\PolylangProvider::class: |
| 26 |
return function_exists('pll__'); |
| 27 |
|
| 28 |
case Provider\TranslatePressProvider::class: |
| 29 |
return class_exists('TRP_Translate_Press') || function_exists('trp_translate'); |
| 30 |
} |
| 31 |
return null; |
| 32 |
} |
| 33 |
} |
| 34 |
|