summary ) { echo '

' . esc_html( $this->summary ) . '

'; } } /** * Implement to output feature box long text * * @since 3.0 */ abstract public function output_feature_box_long(); /** * Create feature * * @since 3.0 */ public function __construct() { /** * Fires when Feature object is created * * @hook ep_feature_create * @param {Feature} $feature Current feature * @since 3.0 */ do_action( 'ep_feature_create', $this ); } /** * Returns requirements status of feature * * @since 2.2 * @return FeatureRequirementsStatus */ public function requirements_status() { $status = new FeatureRequirementsStatus( 0 ); /** * Filter feature requirement status * * @hook ep_{indexable_slug}_index_kill * @param {FeatureRequirementStatus} $status Current feature requirement status * @param {Feature} $feature Current feature * @since 2.2 * @return {FeatureRequirementStatus} New status */ return apply_filters( 'ep_feature_requirements_status', $status, $this ); } /** * Return feature settings * * @since 2.2.1, 4.5.0 started using default settings * @return array */ public function get_settings() { $all_settings = Utils\get_option( 'ep_feature_settings', [] ); $feature_settings = ( ! empty( $all_settings[ $this->slug ] ) ) ? (array) $all_settings[ $this->slug ] : []; $feature_settings = wp_parse_args( $feature_settings, $this->default_settings ); return $feature_settings; } /** * Return a specific setting of the feature * * @since 4.5.0 * @param string $setting_name The setting name * @return mixed */ public function get_setting( string $setting_name ) { $settings = $this->get_settings(); return isset( $settings[ $setting_name ] ) ? $settings[ $setting_name ] : null; } /** * Returns true if feature is active * * @since 2.2 * @return boolean */ public function is_active() { $feature_settings = Utils\get_option( 'ep_feature_settings', [] ); $active = false; if ( ! empty( $feature_settings[ $this->slug ] ) && $feature_settings[ $this->slug ]['active'] ) { $active = true; } /** * Filter whether a feature is active or not * * @hook ep_feature_active * @param {bool} $active Whether feature is active or not * @param {array} $feature_settings Current feature settings * @param {Feature} $feature Current feature * @since 2.2 * @return {bool} New active value */ return apply_filters( 'ep_feature_active', $active, $feature_settings, $this ); } /** * Get the value of the setting that requires a reindex, if it exists. * * @since 4.5.0 * @return mixed */ public function get_reindex_setting() { $settings = $this->get_settings(); $setting = $this->setting_requires_install_reindex; return $settings && $setting && ! empty( $settings[ $setting ] ) ? $settings[ $setting ] : ''; } /** * To be run after initial feature activation * * @since 2.1 */ public function post_activation() { /** * Fires after feature is activated * * @hook ep_feature_post_activation * @param {string} $slug Feature slug * @param {Feature} $feature Current feature * @since 2.1 */ do_action( 'ep_feature_post_activation', $this->slug, $this ); } /** * Outputs feature box * * @since 2.1 */ public function output_feature_box() { $this->output_feature_box_summary(); /** * Fires before feature box summary is shown * * @hook ep_feature_box_summary * @param {string} $slug Feature slug * @param {Feature} $feature Current feature * @since 2.1 */ do_action( 'ep_feature_box_summary', $this->slug, $this ); ?>
output_feature_box_long(); ?>

slug, $this ); ?>
requirements_status(); $sync_url = ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) ? network_admin_url( 'admin.php?page=elasticpress-sync' ) : admin_url( 'admin.php?page=elasticpress-sync' ); ?>
message ) ) : $messages = (array) $requirements_status->message; ?>
requires_install_reindex || $this->setting_requires_install_reindex ) : ?>


output_feature_box_settings(); ?>
', esc_url( plugins_url( '/images/logo-elasticpress-io.svg', EP_FILE ) ) ); } /** * Returns the feature title. * * @since 4.4.1 * @return string */ public function get_title() : string { return $this->title; } /** * Returns the feature short title. * * @since 4.4.1 * @return string */ public function get_short_title() : string { if ( ! empty( $this->short_title ) ) { return $this->short_title; } return $this->get_title(); } /** * Returns whether the feature is visible in the dashboard or not. * * By default, all active features are visible. * * @since 4.5.0 * @return boolean */ public function is_visible() { /** * Filter whether a feature is visible or not in the dashboard. * * Example: * ``` * add_filter( * 'ep_feature_is_visible', * function ( $is_visible, $feature_slug ) { * return 'terms' === $feature_slug ? true : $is_visible; * }, * 10, * 2 * ); * ``` * * @hook ep_feature_is_visible * @param {bool} $is_visible True to display the feature * @param {string} $feature_slug Feature slug * @param {Feature} $feature Feature object * @since 4.5.0 * @return {bool} New $is_visible value */ return apply_filters( 'ep_feature_is_visible', $this->is_visible || $this->is_active(), $this->slug, $this ); } /** * Returns whether the feature is available or not. * * @since 4.5.0 * @return boolean */ public function is_available() : bool { $requirements_status = $this->requirements_status(); /** * Filter whether a feature is available or not. * * Example: * ``` * add_filter( * 'ep_feature_is_available', * function ( $is_available, $feature_slug ) { * return 'terms' === $feature_slug ? true : $is_available; * }, * 10, * 2 * ); * ``` * * @hook ep_feature_is_available * @param {bool} $is_available True if the feature is available * @param {string} $feature_slug Feature slug * @param {Feature} $feature Feature object * @since 4.5.0 * @return {bool} New $is_available value */ return apply_filters( 'ep_feature_is_available', $this->is_visible && 2 !== $requirements_status->code, $this->slug, $this ); } }