render.php
23 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Zenchef\Widget\View; |
| 4 | |
| 5 | use function extract; |
| 6 | use const Zenchef\Widget\ROOT_PATH; |
| 7 | |
| 8 | /** |
| 9 | * Templates carry a .php extension rather than .phtml because `wp i18n make-pot` |
| 10 | * only parses *.php. Under .phtml the translatable strings inside them never |
| 11 | * reached translate.wordpress.org, so no locale could translate them. |
| 12 | * |
| 13 | * @param string $path |
| 14 | * @param array<string, mixed> $variables |
| 15 | * @return string |
| 16 | */ |
| 17 | function render($path, array $variables = []) |
| 18 | { |
| 19 | extract($variables); |
| 20 | |
| 21 | return include ROOT_PATH . 'views/' . $path . '.php'; |
| 22 | } |
| 23 |