lightspeeddevelopment /
lsx-projects
| 1 | <?php |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 2 | |||
| 3 | /** |
||
| 4 | * This class loads the other classes and function files |
||
| 5 | * |
||
| 6 | * @package lsx-projects |
||
| 7 | */ |
||
| 8 | class LSX_Projects_Core { |
||
| 9 | |||
| 10 | /** |
||
| 11 | * Holds class instance |
||
| 12 | * |
||
| 13 | * @since 1.0.0 |
||
| 14 | * |
||
| 15 | * @var object \lsx_projects\classes\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
|
|||
| 32 | add_action( 'init', array( $this, 'cmb2_post_search_ajax' ) ); |
||
| 33 | $this->load_vendors(); |
||
| 34 | } |
||
|
0 ignored issues
–
show
|
|||
| 35 | |||
| 36 | /** |
||
| 37 | * Return an instance of this class. |
||
| 38 | * |
||
| 39 | * @since 1.0.0 |
||
| 40 | * |
||
| 41 | * @return object \lsx_projects\classes\Core() A single instance of this class. |
||
| 42 | */ |
||
| 43 | public static function get_instance() { |
||
|
0 ignored issues
–
show
|
|||
| 44 | |||
| 45 | // If the single instance hasn't been set, set it now. |
||
| 46 | if ( null === self::$instance ) { |
||
|
0 ignored issues
–
show
|
|||
| 47 | self::$instance = new self(); |
||
| 48 | } |
||
| 49 | |||
| 50 | return self::$instance; |
||
| 51 | |||
| 52 | } |
||
|
0 ignored issues
–
show
|
|||
| 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
|
|||
| 60 | require_once LSX_PROJECTS_PATH . 'vendor/CMB2/init.php'; |
||
| 61 | } |
||
| 62 | } |
||
|
0 ignored issues
–
show
|
|||
| 63 | |||
| 64 | /** |
||
| 65 | * Returns the post types currently active |
||
| 66 | * |
||
| 67 | * @return void |
||
|
0 ignored issues
–
show
|
|||
| 68 | */ |
||
| 69 | public function get_post_types() { |
||
| 70 | $post_types = apply_filters( 'lsx_projects_post_types', isset( $this->post_types ) ); |
||
| 71 | foreach ( $post_types as $index => $post_type ) { |
||
|
0 ignored issues
–
show
|
|||
| 72 | $is_disabled = \cmb2_get_option( 'lsx_projects_options', $post_type . '_disabled', false ); |
||
| 73 | if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) { |
||
|
0 ignored issues
–
show
|
|||
| 74 | unset( $post_types[ $index ] ); |
||
| 75 | } |
||
| 76 | } |
||
|
0 ignored issues
–
show
|
|||
| 77 | return $post_types; |
||
| 78 | } |
||
|
0 ignored issues
–
show
|
|||
| 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_PROJECTS_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
|
|||
| 88 | $this->cmb2_post_search_ajax = \MAG_CMB2_Field_Post_Search_Ajax::get_instance(); |
||
| 89 | } |
||
| 90 | } |
||
|
0 ignored issues
–
show
|
|||
| 91 | } |
||
| 92 | |||
| 93 | LSX_Projects_Core::get_instance(); |
||
| 94 |