1
|
|
|
<?php |
|
|
|
|
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() { |
|
|
|
|
32
|
|
|
add_action( 'init', array( $this, 'cmb2_post_search_ajax' ) ); |
33
|
|
|
$this->load_vendors(); |
34
|
|
|
} |
|
|
|
|
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() { |
|
|
|
|
44
|
|
|
|
45
|
|
|
// If the single instance hasn't been set, set it now. |
46
|
|
|
if ( null === self::$instance ) { |
|
|
|
|
47
|
|
|
self::$instance = new self(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
return self::$instance; |
51
|
|
|
|
52
|
|
|
} |
|
|
|
|
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Loads the plugin functions. |
56
|
|
|
*/ |
57
|
|
|
private function load_vendors() { |
58
|
|
|
// Configure custom fields. |
59
|
|
|
if ( ! class_exists( 'CMB2' ) ) { |
|
|
|
|
60
|
|
|
require_once LSX_TEAM_PATH . 'vendor/CMB2/init.php'; |
61
|
|
|
} |
62
|
|
|
} |
|
|
|
|
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Returns the post types currently active |
66
|
|
|
* |
67
|
|
|
* @return void |
|
|
|
|
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 ) { |
|
|
|
|
72
|
|
|
$is_disabled = \cmb2_get_option( 'lsx_team_options', $post_type . '_disabled', false ); |
73
|
|
|
if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) { |
|
|
|
|
74
|
|
|
unset( $post_types[ $index ] ); |
75
|
|
|
} |
76
|
|
|
} |
|
|
|
|
77
|
|
|
return $post_types; |
78
|
|
|
} |
|
|
|
|
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' ) ) { |
|
|
|
|
88
|
|
|
$this->cmb2_post_search_ajax = \MAG_CMB2_Field_Post_Search_Ajax::get_instance(); |
89
|
|
|
} |
90
|
|
|
} |
|
|
|
|
91
|
|
|
} |
92
|
|
|
LSX_Team_Core::get_instance(); |
93
|
|
|
|