PluginProbe
Panorama – Turn Photos into Immersive Virtual Tours / trunk
Panorama – Turn Photos into Immersive Virtual Tours vtrunk
1.8.0 1.7.4 1.7.3 1.7.2 1.7.1 1.7.0 1.6.1 trunk 1.0.0 1.0.1 1.0.10 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.3 1.1.4 1.1.5 1.1.6 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 All 38 releases
panorama / inc / Init.php

Init.php in Panorama – Turn Photos into Immersive Virtual Tours trunk, at inc/Init.php

80 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BPPIV;
4
5 if (!defined('ABSPATH')) {
6 exit;
7 }
8
9 class Init{
10 private static $instance = null;
11 private function __construct() {
12 add_action('woocommerce_after_register_post_type', [$this, 'load_woocommerce_files']);
13 }
14
15 public static function instance() {
16 if ( is_null( self::$instance ) ) {
17 self::$instance = new self();
18 self::$instance->init();
19 }
20 return self::$instance;
21 }
22
23 public static function get_services(){
24 return [
25 Base\registerPostType::class,
26 Woocommerce\ProductView::class,
27 Base\EnqueueAssets::class,
28 Base\Blocks::class,
29 Base\Admin::class,
30 Base\Ajax::class,
31 Analytics\AnalyticsManager::class,
32 ];
33 }
34
35 public static function get_woocommerce_services(){
36 return [
37 Woocommerce\ProductMeta::class,
38 ];
39 }
40
41 public static function init(){
42 foreach(self::get_services() as $class){
43 if($class = self::require_file($class)){
44 $services = self::instantiate($class);
45 if(method_exists($services, 'register')){
46 $services->register();
47 }
48 }
49 }
50 }
51
52 public function load_woocommerce_files(){
53 foreach(self::get_woocommerce_services() as $class){
54 if($class = self::require_file($class)){
55 $services = self::instantiate($class);
56 if(method_exists($services, 'register')){
57 $services->register();
58 }
59 }
60 }
61 }
62
63 public static function require_file($class){
64 $file = str_replace('\\', '/', $class);
65 $file = BPPIV_PATH.str_replace('BPPIV', 'inc', $file).'.php';
66 if(file_exists($file)){
67 require_once($file);
68 return $class;
69 }
70 return false;
71 }
72
73 private static function instantiate($class){
74 if(class_exists($class)){
75 return new $class();
76 }
77
78 return new \stdClass();
79 }
80 }