-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuddypress-global-search.php
114 lines (94 loc) · 3.18 KB
/
buddypress-global-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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* Plugin Name: BuddyPress Global Search
* Plugin URI: https://www.buddyboss.com/product/buddypress-global-search/
* Description: Ajax powered global BuddyPress search
* Author: BuddyBoss
* Author URI: http://buddyboss.com
* Version: 1.2.1
*/
// Exit if accessed directly
if (!defined('ABSPATH'))
exit;
/**
* ========================================================================
* CONSTANTS
* ========================================================================
*/
// Codebase version
if (!defined('BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_VERSION')) {
define('BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_VERSION', '1.2.1');
}
// Database version
if (!defined('BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_DB_VERSION')) {
define('BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_DB_VERSION', 1);
}
// Directory
if (!defined('BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_DIR')) {
define('BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_DIR', trailingslashit(plugin_dir_path(__FILE__)));
}
// Url
if (!defined('BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_URL')) {
$plugin_url = plugin_dir_url(__FILE__);
// If we're using https, update the protocol. Workaround for WP13941, WP15928, WP19037.
if (is_ssl())
$plugin_url = str_replace('http://', 'https://', $plugin_url);
define('BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_URL', $plugin_url);
}
// File
if (!defined('BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_FILE')) {
define('BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_FILE', __FILE__);
}
/**
* ========================================================================
* MAIN FUNCTIONS
* ========================================================================
*/
/**
* Main
*
* @return void
* @since 1.0.0
*/
function buddyboss_global_search_init() {
global $bp, $buddyboss_global_search;
$main_include = BUDDYBOSS_GLOBAL_SEARCH_PLUGIN_DIR . 'includes/main-class.php';
try {
if (file_exists($main_include)) {
require( $main_include );
} else {
$msg = sprintf(__("Couldn't load main class at:<br/>%s", 'buddypress-global-search'), $main_include);
throw new Exception($msg, 404);
}
} catch (Exception $e) {
$msg = sprintf(__("<h1>Fatal error:</h1><hr/><pre>%s</pre>", 'buddypress-global-search'), $e->getMessage());
echo $msg;
}
$buddyboss_global_search = BuddyBoss_Global_Search_Plugin::instance();
}
add_action('plugins_loaded', 'buddyboss_global_search_init');
/**
* Must be called after hook 'plugins_loaded'
*
* @return BuddyPress Global Search main/global object
* @see class BuddyBoss_Global_Search
* @since 1.0.0
*/
function buddyboss_global_search() {
global $buddyboss_global_search;
return $buddyboss_global_search;
}
/**
* Register BuddyBoss Menu Page
*/
if ( !function_exists( 'register_buddyboss_menu_page' ) ) {
function register_buddyboss_menu_page() {
// Set position with odd number to avoid confict with other plugin/theme.
add_menu_page( 'BuddyBoss', 'BuddyBoss', 'manage_options', 'buddyboss-settings', '', buddyboss_global_search()->assets_url . '/images/logo.svg', 3 );
// To remove empty parent menu item.
add_submenu_page( 'buddyboss-settings', 'BuddyBoss', 'BuddyBoss', 'manage_options', 'buddyboss-settings' );
remove_submenu_page( 'buddyboss-settings', 'buddyboss-settings' );
}
add_action( 'admin_menu', 'register_buddyboss_menu_page' );
}
?>