PluginProbe
Wingify / 4.15
Wingify v4.15
4.15 4.16 trunk 1.0 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 All 39 releases
visual-web-optimizer / VwoTemplater.php

VwoTemplater.php in Wingify 4.15, at VwoTemplater.php

31 lines 744 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) or exit;
3
4 class VwoTemplater {
5 protected $dirs = [];
6
7 public function __construct( array $dirs = [ '' ] ) {
8 $this->dirs = $dirs;
9 }
10
11 protected function find( $file ) {
12 foreach ( $this->dirs as $dir ) {
13 if ( is_file( $path = ( $dir ? trailingslashit( $dir ) : '' ) . $file ) ) return $path;
14 elseif ( is_file( $path .= '.php' ) ) return $path;
15 }
16 return false;
17 }
18
19 public function render( string $file, array $vars = [] ) {
20 if ( ! $file = $this->find( $file ) ) {
21 return false;
22 }
23 if ( $vars ) extract( $vars, EXTR_SKIP );
24
25 ob_start();
26 include $file;
27
28 return ob_get_clean();
29 }
30 }
31