LSX_Team_Core   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 19
c 2
b 0
f 0
dl 0
loc 81
rs 10
wmc 12

5 Methods

Rating   Name   Duplication   Size   Complexity  
A load_vendors() 0 4 2
A get_post_types() 0 9 5
A cmb2_post_search_ajax() 0 4 2
A get_instance() 0 8 2
A __construct() 0 3 1
1
<?php
0 ignored issues
show
Coding Style introduced by
This file is missing a doc comment.
Loading history...
2
3
/**
4
 * This class loads the other classes and function files
5
 *
6
 * @package lsx-team
7
 */
8
class LSX_Team_Core {
9
10
	/**
11
	 * Holds class instance
12
	 *
13
	 * @since 1.0.0
14
	 *
15
	 * @var      object LSX_Team_Core()
16
	 */
17
	protected static $instance = null;
18
19
	/**
20
	 * Holds class instance
21
	 *
22
	 * @since 1.0.0
23
	 *
24
	 * @var      object \MAG_CMB2_Field_Post_Search_Ajax()
25
	 */
26
	public $cmb2_post_search_ajax = false;
27
28
	/**
29
	 * Contructor
30
	 */
31
	public function __construct() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
32
		add_action( 'init', array( $this, 'cmb2_post_search_ajax' ) );
33
		$this->load_vendors();
34
	}
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...
35
36
	/**
37
	 * Return an instance of this class.
38
	 *
39
	 * @since 1.0.0
40
	 *
41
	 * @return    object \lsx_team\classes\Core()    A single instance of this class.
42
	 */
43
	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...
44
45
		// If the single instance hasn't been set, set it now.
46
		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...
47
			self::$instance = new self();
48
		}
49
50
		return self::$instance;
51
52
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
53
54
	/**
55
	 * Loads the plugin functions.
56
	 */
57
	private function load_vendors() {
58
		// Configure custom fields.
59
		if ( ! class_exists( 'CMB2' ) ) {
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...
60
			require_once LSX_TEAM_PATH . 'vendor/CMB2/init.php';
61
		}
62
	}
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...
63
64
	/**
65
	 * Returns the post types currently active
66
	 *
67
	 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
68
	 */
69
	public function get_post_types() {
70
		$post_types = apply_filters( 'lsx_team_post_types', isset( $this->post_types ) );
71
		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...
72
			$is_disabled = \cmb2_get_option( 'lsx_team_options', $post_type . '_disabled', false );
73
			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...
74
				unset( $post_types[ $index ] );
75
			}
76
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
77
		return $post_types;
78
	}
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...
79
80
	/**
81
	 * Includes the Post Search Ajax if it is there.
82
	 *
83
	 * @return void
84
	 */
85
	public function cmb2_post_search_ajax() {
86
		require_once LSX_TEAM_PATH . 'vendor/lsx-field-post-search-ajax/cmb-field-post-search-ajax.php';
87
		if ( method_exists( 'MAG_CMB2_Field_Post_Search_Ajax', 'get_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...
88
			$this->cmb2_post_search_ajax = \MAG_CMB2_Field_Post_Search_Ajax::get_instance();
89
		}
90
	}
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...
91
}
92
LSX_Team_Core::get_instance();
93