-
Notifications
You must be signed in to change notification settings - Fork 0
/
obi-remove-post-types-from-search.php
90 lines (62 loc) · 2.22 KB
/
obi-remove-post-types-from-search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* Plugin Name: Obi Remove Post Types from Search
* Description: Include or exclude (custom) post types from the WordPress search feature.
* Version: 1.0.0
* Author: Obi Juan
* Author URI: https://obijuan.dev
* Plugin URI: https://obijuan.dev/obi-remove-post-types-from-search
* License: GPL2 or later
* Textdomain: obi-remove-post-types-from-search
* @since 1.0.0
*
*/
if (!defined('ABSPATH')) {
exit('Trying what?');
}
require_once plugin_dir_path(__FILE__) . 'vendor/autoload.php';
use ObiRemovePostTypesFromSearch\Includes\Admin\AdminPage;
use ObiRemovePostTypesFromSearch\Includes\PostTypes;
final class Obi_Init
{
private static $instance;
private function __construct()
{
self::define_constants();
}
public static function get_instance()
{
if (!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
private static function define_constants()
{
define('OBI_REMOVE_POST_TYPES_FROM_SEARCH_VERSION', '1.0.0');
define('OBI_REMOVE_POST_TYPES_FROM_SEARCH__TEXTDOMAIN', 'obi-remove-post-types-from-search');
define('OBI_REMOVE_POST_TYPES_FROM_SEARCH_DIRNAME', plugin_basename(dirname(__FILE__)));
define('OBI_REMOVE_POST_TYPES_FROM_SEARCH_FILE', __FILE__);
define('OBI_REMOVE_POST_TYPES_FROM_SEARCH_PREFIX', 'obi_remove_post_types_from_search');
define('OBI_REMOVE_POST_TYPES_FROM_SEARCH_PATH', plugin_dir_path(OBI_REMOVE_POST_TYPES_FROM_SEARCH_FILE));
define('OBI_REMOVE_POST_TYPES_FROM_SEARCH_URL', plugin_dir_url(OBI_REMOVE_POST_TYPES_FROM_SEARCH_FILE));
}
public static function load_obi_plugin()
{
// On plugins loaded...
AdminPage::get_instance();
PostTypes::get_instance();
}
public static function activate()
{
// On plugin activation...
PostTypes::initialize_post_type_statuses();
}
public static function deactivate()
{
// On plugin deactivation...
}
}
$obi_plugin = Obi_Init::get_instance();
register_activation_hook(OBI_REMOVE_POST_TYPES_FROM_SEARCH_FILE, array($obi_plugin, 'activate'));
add_action('plugins_loaded', array($obi_plugin, 'load_obi_plugin'));