PluginProbe
WP Ultimate Post Grid / 2.5.0
WP Ultimate Post Grid v2.5.0
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / vendor / vafpress / classes / view.php

view.php in WP Ultimate Post Grid 2.5.0, at vendor/vafpress/classes/view.php

61 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * A Singleton class for loading view template
5 */
6 class VP_View
7 {
8
9 /**
10 * Singleton instance of the class
11 * @var Option_View
12 */
13 private static $_instance;
14
15 private $_views;
16
17 private function __construct()
18 {
19 $this->_views = array();
20 }
21
22 public static function instance()
23 {
24 if (is_null(self::$_instance))
25 {
26 self::$_instance = new self();
27 }
28 return self::$_instance;
29 }
30
31 /**
32 * Load view file
33 * @param String $field_view_file Name of the view file
34 * @param Array $data Array of data to be binded on the view
35 * @return String The result view
36 */
37 public function load($field_view_file, $data = array())
38 {
39 if (array_key_exists('field_view_file', $data))
40 {
41 throw new Exception("Sorry 'field_view_file' variable name can't be used.");
42 }
43
44 $view_file = VP_FileSystem::instance()->resolve_path('views', $field_view_file);
45
46 if($view_file === false)
47 {
48 throw new Exception("View file not found.");
49 }
50
51 extract($data);
52 ob_start();
53 include $view_file;
54 return ob_get_clean();
55 }
56
57 }
58
59 /**
60 * EOF
61 */