BP_Search::instance()
Insures that only one instance of Class exists in memory at any one time. Also prevents needing to define globals all over the place.
Description
See also
Return
(object) bp_search_Plugin
Source
File: bp-search/classes/class-bp-search.php
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 self();
//create instances of helpers and associate them with types
add_action( 'init', array( $instance, 'load_search_helpers' ), 80 );
add_action( 'wp_ajax_bp_search_ajax', array( $instance, 'ajax_search' ) );
add_action( 'wp_ajax_nopriv_bp_search_ajax', array( $instance, 'ajax_search' ) );
}
// Always return the instance
return $instance;
}
Changelog
| Version | Description |
|---|---|
| BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.