| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class LP_Template |
| 5 |
* |
| 6 |
* @since 3.3.0 |
| 7 |
*/ |
| 8 |
class LP_Template implements ArrayAccess { |
| 9 |
/** |
| 10 |
* @var LP_Template |
| 11 |
*/ |
| 12 |
protected static $instance = null; |
| 13 |
|
| 14 |
public $templates = array(); |
| 15 |
|
| 16 |
/** |
| 17 |
* LP_Template constructor. |
| 18 |
*/ |
| 19 |
protected function __construct() { |
| 20 |
$this->templates = apply_filters( |
| 21 |
'learn-press/templates-classes', |
| 22 |
array( |
| 23 |
'general' => include_once 'templates/class-lp-template-general.php', |
| 24 |
'course' => include_once 'templates/class-lp-template-course.php', |
| 25 |
'checkout' => include_once 'templates/class-lp-template-checkout.php', |
| 26 |
'profile' => include_once 'templates/class-lp-template-profile.php', |
| 27 |
) |
| 28 |
); |
| 29 |
} |
| 30 |
|
| 31 |
public function has_content( $where ) { |
| 32 |
return has_action( $where ); |
| 33 |
} |
| 34 |
|
| 35 |
public function offsetGet( $offset ) { |
| 36 |
return ! empty( $this->templates[ $offset ] ) ? $this->templates[ $offset ] : false; |
| 37 |
} |
| 38 |
|
| 39 |
public function offsetSet( $offset, $value ) { |
| 40 |
return false; |
| 41 |
} |
| 42 |
|
| 43 |
public function offsetExists( $offset ) { |
| 44 |
return ! empty( $this->templates[ $offset ] ); |
| 45 |
} |
| 46 |
|
| 47 |
public function offsetUnset( $offset ) { |
| 48 |
return false; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Instance lp template |
| 53 |
* |
| 54 |
* @return LP_Template |
| 55 |
*/ |
| 56 |
public static function instance() { |
| 57 |
if ( ! self::$instance ) { |
| 58 |
self::$instance = new self(); |
| 59 |
} |
| 60 |
|
| 61 |
return self::$instance; |
| 62 |
} |
| 63 |
} |
| 64 |
|