| 1 |
<?php |
| 2 |
|
| 3 |
namespace FilterEverything\Filter; |
| 4 |
|
| 5 |
if ( ! defined('WPINC') ) { |
| 6 |
wp_die(); |
| 7 |
} |
| 8 |
|
| 9 |
class TemplateManager |
| 10 |
{ |
| 11 |
private $pluginRootDir; |
| 12 |
|
| 13 |
private $themeRootDir; |
| 14 |
|
| 15 |
private $pluginUrl; |
| 16 |
|
| 17 |
public function __construct( $pluginFilePath ) |
| 18 |
{ |
| 19 |
$this->pluginRootDir = $pluginFilePath; |
| 20 |
$this->pluginUrl = plugin_dir_url( $pluginFilePath ); |
| 21 |
$this->themeRootDir = get_stylesheet_directory(); |
| 22 |
} |
| 23 |
|
| 24 |
public function includeAdminView( $path, array $variables = [] ) |
| 25 |
{ |
| 26 |
$file = $this->pluginRootDir . 'views/admin/' . $path . '.php'; |
| 27 |
|
| 28 |
if( file_exists( $file ) ){ |
| 29 |
extract( $variables ); |
| 30 |
include $file; |
| 31 |
} |
| 32 |
|
| 33 |
} |
| 34 |
|
| 35 |
public function includeFrontView( $path, $variables = [] ) |
| 36 |
{ |
| 37 |
$file = locate_template( array( FLRT_TEMPLATES_DIR_NAME . '/' . $path . '.php') ); |
| 38 |
|
| 39 |
if( '' === $file ){ |
| 40 |
$file = $this->pluginRootDir . 'views/frontend/' . $path . '.php'; |
| 41 |
} |
| 42 |
|
| 43 |
if( file_exists( $file ) ){ |
| 44 |
extract( $variables ); |
| 45 |
include $file; |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
public function locateTemplate( $path ) |
| 50 |
{ |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
} |