PluginProbe
HyperPay Payments / trunk
HyperPay Payments vtrunk
6.6.0 trunk 1.7 1.8 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.1.0 2.2.0 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.5 4.0.0 4.0.2 All 34 releases
hyperpay-gateways / src / Helpers / View.php

View.php in HyperPay Payments trunk, at src/Helpers/View.php

37 lines 924 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Hyperpay\Gateways\Helpers;
4
5 if (! defined('ABSPATH')) exit;
6
7 use Hyperpay\Gateways\Main;
8
9 final class View
10 {
11 public static function render($name, $params = [])
12 {
13 $loader = new \Twig\Loader\FilesystemLoader(Main::ROOT_PATH . "/assets/templates");
14 $twig = new \Twig\Environment($loader);
15
16 $params = static::esc($params);
17
18 // rendering the template HTML, JS and CSS
19 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
20 echo ($twig->render($name, $params));
21 return;
22 }
23
24 public static function esc($value)
25 {
26 if (is_array($value)) {
27 $esc_values = [];
28 foreach ($value as $key => $nested_value) {
29 $esc_values[$key] = static::esc($nested_value);
30 }
31 return $esc_values;
32 }
33
34 return esc_html($value);
35 }
36 }
37