Ga_Admin.php
9 years ago
Ga_Autoloader.php
9 years ago
Ga_Frontend.php
9 years ago
Ga_Helper.php
9 years ago
Ga_Hook.php
9 years ago
Ga_Stats.php
9 years ago
Ga_View.php
9 years ago
Ga_View.php
39 lines
| 1 | <?php |
| 2 | |
| 3 | class Ga_View { |
| 4 | |
| 5 | /** |
| 6 | * Name of the view folder. |
| 7 | */ |
| 8 | const PATH = 'view'; |
| 9 | |
| 10 | /** |
| 11 | * Loads given view file and it's data. |
| 12 | * Displays view or returns HTML code. |
| 13 | * |
| 14 | * @param string $view Filename |
| 15 | * @param array $data Data array |
| 16 | * @param bool $html Whether to display or return HTML code. |
| 17 | * |
| 18 | * @return string |
| 19 | */ |
| 20 | public static function load( $view, $data_array = array(), $html = false ) { |
| 21 | if ( ! empty( $view ) ) { |
| 22 | foreach ( $data_array as $k => $v ) { |
| 23 | $$k = $v; |
| 24 | } |
| 25 | ob_start(); |
| 26 | include GA_PLUGIN_DIR . "/" . self::PATH . "/" . $view . ".php"; |
| 27 | if ( $html ) { |
| 28 | return ob_get_clean(); |
| 29 | } else { |
| 30 | echo ob_get_clean(); |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | // private static function buffer($buffer) { |
| 36 | // $data = $data_array; |
| 37 | // return $buffer; |
| 38 | // } |
| 39 | } |