/** * 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(); }
/** * Main BuddyPress Global Search Instance. * * Insures that only one instance of BuddyPress Global Search exists in memory at any * one time. Also prevents needing to define globals all over the place. * * @since 1.0.0 * * @static object $instance * @uses BuddyBoss_Global_Search_Plugin::setup_globals() Setup the globals needed. * @uses BuddyBoss_Global_Search_Plugin::setup_actions() Setup the hooks and actions. * @uses BuddyBoss_Global_Search_Plugin::setup_textdomain() Setup the plugin's language file. * @see buddyboss_global_search() * * @return object BuddyBoss_Global_Search_Plugin */ public static function instance() { // Store the instance locally to avoid private static replication static $instance = null; // Only run these methods if they haven't been run previously if (null === $instance) { $instance = new BuddyBoss_Global_Search_Plugin(); $instance->setup_globals(); $instance->setup_actions(); $instance->setup_textdomain(); } // Always return the instance return $instance; }