=' ) ) {
add_action(
'admin_notices',
function() {
?>
register( new Indexable\Post\Post() );
/**
* Handle features
*/
Features::factory()->register_feature(
new Feature\Search\Search()
);
Features::factory()->register_feature(
new Feature\InstantResults\InstantResults()
);
Features::factory()->register_feature(
new Feature\Autosuggest\Autosuggest()
);
Features::factory()->register_feature(
new Feature\DidYouMean\DidYouMean()
);
Features::factory()->register_feature(
new Feature\WooCommerce\WooCommerce()
);
Features::factory()->register_feature(
new Feature\Facets\Facets()
);
Features::factory()->register_feature(
new Feature\RelatedPosts\RelatedPosts()
);
Features::factory()->register_feature(
new Feature\SearchOrdering\SearchOrdering()
);
Features::factory()->register_feature(
new Feature\ProtectedContent\ProtectedContent()
);
Features::factory()->register_feature(
new Feature\Documents\Documents()
);
Features::factory()->register_feature(
new Feature\Comments\Comments()
);
/**
* Filter whether the Users feature should be registered or not.
*
* The Users feature is going to be migrated to ElasticPress Labs. If EP Labs is enabled
* and in a more recent version, it will change this to false and load its own version
* of the Users feature.
*
* @hook ep_user_register_feature
* @since 4.5.0
* @param {bool} $version Version
* @return {bool} New version
*/
if ( apply_filters( 'ep_user_register_feature', true ) ) {
Features::factory()->register_feature(
new Feature\Users\Users()
);
}
Features::factory()->register_feature(
new Feature\Terms\Terms()
);
/**
* Register search algorithms
*/
SearchAlgorithms::factory()->register( new SearchAlgorithm\DefaultAlgorithm() );
SearchAlgorithms::factory()->register( new SearchAlgorithm\Version_350() );
SearchAlgorithms::factory()->register( new SearchAlgorithm\Version_400() );
/**
* Filter the query logger object
*
* @since 4.4.0
* @hook ep_query_logger
* @param {QueryLogger} $query_logger Default query logger
* @return {QueryLogger} New query logger
*/
$query_logger = apply_filters( 'ep_query_logger', new \ElasticPress\QueryLogger() );
get_container()->set( '\ElasticPress\QueryLogger', $query_logger, true );
get_container()->set( '\ElasticPress\BlockTemplateUtils', new \ElasticPress\BlockTemplateUtils(), true );
}
add_action( 'plugins_loaded', __NAMESPACE__ . '\register_indexable_posts' );
/**
* Set the availability of dashboard sync functionality. Defaults to true (enabled).
*
* Sync can be disabled by defining EP_DASHBOARD_SYNC as false in wp-config.php.
* NOTE: Must be defined BEFORE `require_once(ABSPATH . 'wp-settings.php');` in wp-config.php.
*
* @since 2.3
*/
if ( ! defined( 'EP_DASHBOARD_SYNC' ) ) {
define( 'EP_DASHBOARD_SYNC', true );
}
/**
* Setup installer
*/
Installer::factory();
/**
* Setup screen
*/
Screen::factory();
/**
* Setup dashboard
*/
require_once __DIR__ . '/includes/dashboard.php';
Dashboard\setup();
/**
* WP CLI Commands
*/
if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_command( 'elasticpress', __NAMESPACE__ . '\Command' );
}
/**
* Setup upgrades
*/
Upgrades::factory();
/**
* Handle upgrades. Certain version require a re-sync on upgrade.
* Deprecated in favor of `\ElasticPress\Upgrades::factory()`.
*
* @since 2.2
*/
function handle_upgrades() {
_deprecated_function( __CLASS__, '3.5.2', '\ElasticPress\Upgrades::factory()' );
}
/**
* Load text domain and handle debugging
*
* @since 2.2
*/
function setup_misc() {
load_plugin_textdomain( 'elasticpress', false, basename( __DIR__ ) . '/lang' ); // Load any available translations first.
if ( is_user_logged_in() && ! defined( 'WP_EP_DEBUG' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
define( 'WP_EP_DEBUG', is_plugin_active( 'debug-bar-elasticpress/debug-bar-elasticpress.php' ) );
}
}
add_action( 'plugins_loaded', __NAMESPACE__ . '\setup_misc' );
/**
* Set up role(s) with EP capability
*/
function setup_roles() {
// add custom capabilities to admin role
$role = get_role( 'administrator' );
$role->add_cap( Utils\get_capability() );
}
register_activation_hook( __FILE__, __NAMESPACE__ . '\setup_roles' );
/**
* Fires after Elasticpress plugin is loaded
*
* @since 2.0
* @hook elasticpress_loaded
*/
do_action( 'elasticpress_loaded' );