| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* This file is part of the WindPress package. |
| 5 |
* |
| 6 |
* (c) Joshua Gugun Siagian <suabahasa@gmail.com> |
| 7 |
* |
| 8 |
* For the full copyright and license information, please view the LICENSE |
| 9 |
* file that was distributed with this source code. |
| 10 |
*/ |
| 11 |
declare (strict_types=1); |
| 12 |
namespace WindPress\WindPress\Integration\Timber; |
| 13 |
|
| 14 |
use WindPress\WindPress\Integration\IntegrationInterface; |
| 15 |
use WindPress\WindPress\Utils\Common; |
| 16 |
use WindPress\WindPress\Utils\Config; |
| 17 |
/** |
| 18 |
* @author Joshua Gugun Siagian <suabahasa@gmail.com> |
| 19 |
*/ |
| 20 |
class Main implements IntegrationInterface |
| 21 |
{ |
| 22 |
public function __construct() |
| 23 |
{ |
| 24 |
add_filter('f!windpress/core/cache:compile.providers', fn(array $providers): array => $this->register_provider($providers)); |
| 25 |
} |
| 26 |
public function get_name(): string |
| 27 |
{ |
| 28 |
return 'timber'; |
| 29 |
} |
| 30 |
public function is_enabled(): bool |
| 31 |
{ |
| 32 |
return (bool) apply_filters('f!windpress/integration/timber:enabled', Config::get(sprintf('integration.%s.enabled', $this->get_name()), \true)); |
| 33 |
} |
| 34 |
public function register_provider(array $providers): array |
| 35 |
{ |
| 36 |
$providers[] = ['id' => $this->get_name(), 'name' => __('Timber', 'windpress'), 'description' => __('Timber integration', 'windpress'), 'callback' => Config::get(sprintf('integration.%s.compile.enabled', $this->get_name()), \true) ? \WindPress\WindPress\Integration\Timber\Compile::class : static fn() => [], 'enabled' => $this->is_enabled(), 'type' => 'plugin', 'homepage' => 'https://upstatement.com/timber/?ref=windpress', 'is_installed_active' => static function () { |
| 37 |
$is = -1; |
| 38 |
$is += Common::is_plugin_installed('Timber') ? 1 : 0; |
| 39 |
$is += Common::is_plugin_active_by_name('Timber') ? 1 : 0; |
| 40 |
return $is; |
| 41 |
}]; |
| 42 |
return $providers; |
| 43 |
} |
| 44 |
} |
| 45 |
|