Core::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style introduced by
This file is missing a doc comment.
Loading history...
2
namespace lsx_health_plan\classes;
3
4
/**
5
 * This class loads the other classes and function files
6
 *
7
 * @package lsx-health-plan
8
 */
9
class Core {
10
11
	/**
12
	 * Holds class instance
13
	 *
14
	 * @since 1.0.0
15
	 *
16
	 * @var      object \lsx_health_plan\classes\Core()
17
	 */
18
	protected static $instance = null;
19
20
	/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
21
	 * @var object \lsx_health_plan\classes\Setup();
22
	 */
23
	public $setup;
24
25
	/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
26
	 * @var object \lsx_health_plan\classes\Admin();
27
	 */
28
	public $admin;
29
30
	/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
31
	 * @var object \lsx_health_plan\classes\Frontend();
32
	 */
33
	public $frontend;
34
35
	/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
36
	 * @var object \lsx_health_plan\classes\Integrations();
37
	 */
38
	public $integrations;
39
40
	/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
41
	 * @var object \lsx_health_plan\classes\Integrations();
42
	 */
43
	public $scpo_engine;
44
45
	/**
46
	 * Constructor
47
	 */
48
	public function __construct() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
49
		$this->load_includes();
50
		$this->load_classes();
51
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
52
53
	/**
54
	 * Return an instance of this class.
55
	 *
56
	 * @since 1.0.0
57
	 *
58
	 * @return    object \lsx_health_plan\classes\Core()    A single instance of this class.
59
	 */
60
	public static function get_instance() {
0 ignored issues
show
Coding Style introduced by
Expected 0 blank lines after opening function brace; 1 found
Loading history...
61
62
		// If the single instance hasn't been set, set it now.
63
		if ( null === self::$instance ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
64
			self::$instance = new self();
65
		}
66
67
		return self::$instance;
68
69
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
70
71
	/**
72
	 * Loads the variable classes and the static classes.
73
	 */
74
	private function load_classes() {
0 ignored issues
show
Coding Style introduced by
Expected 0 blank lines after opening function brace; 1 found
Loading history...
75
76
		require_once LSX_HEALTH_PLAN_PATH . 'classes/class-setup.php';
77
		$this->setup = Setup::get_instance();
78
79
		require_once LSX_HEALTH_PLAN_PATH . 'classes/class-admin.php';
80
		$this->admin = Admin::get_instance();
81
82
		require_once LSX_HEALTH_PLAN_PATH . 'classes/class-frontend.php';
83
		$this->frontend = Frontend::get_instance();
84
85
		require_once LSX_HEALTH_PLAN_PATH . 'classes/class-integrations.php';
86
		$this->integrations = Integrations::get_instance();
87
88
		require_once LSX_HEALTH_PLAN_PATH . 'classes/class-scpo-engine.php';
89
		$this->scpo_engine = SCPO_Engine::get_instance();
90
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
91
92
	/**
93
	 * Loads the plugin functions.
94
	 */
95
	private function load_includes() {
96
		require_once LSX_HEALTH_PLAN_PATH . '/includes/functions.php';
97
		require_once LSX_HEALTH_PLAN_PATH . '/includes/functions/triggers.php';
98
		require_once LSX_HEALTH_PLAN_PATH . '/includes/functions/recipes.php';
99
		require_once LSX_HEALTH_PLAN_PATH . '/includes/functions/plan.php';
100
		require_once LSX_HEALTH_PLAN_PATH . '/includes/conditionals.php';
101
		require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags.php';
102
		require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/exercise.php';
103
		require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/gallery.php';
104
		require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/plan.php';
105
		require_once LSX_HEALTH_PLAN_PATH . '/includes/shortcodes.php';
106
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
107
108
	/**
109
	 * Returns the post types currently active
110
	 *
111
	 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
112
	 */
113
	public function get_post_types() {
114
		$post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) );
115
		foreach ( $post_types as $index => $post_type ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
116
			$is_disabled = \cmb2_get_option( 'lsx_health_plan_options', $post_type . '_disabled', false );
117
			if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
118
				unset( $post_types[ $index ] );
119
			}
120
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
121
		return $post_types;
122
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
123
}
124