slug = 'autosuggest';
$this->title = esc_html__( 'Autosuggest', 'elasticpress' );
$this->summary = __( 'Suggest relevant content as text is entered into the search field.', 'elasticpress' );
$this->docs_url = __( 'https://elasticpress.zendesk.com/hc/en-us/articles/360050447492-Configuring-ElasticPress-via-the-Plugin-Dashboard#autosuggest', 'elasticpress' );
$this->requires_install_reindex = true;
$this->default_settings = [
'endpoint_url' => '',
'autosuggest_selector' => '',
'trigger_ga_event' => '0',
];
$this->available_during_installation = true;
parent::__construct();
}
/**
* Output feature box long
*
* @since 2.4
*/
public function output_feature_box_long() {
?>
=' ) || 0 === stripos( $wp_version, '5.2-' ) ) {
printf(
/* translators: 1:
tag (ElasticPress.io); 2. ; 3:
tag (KB article); 4. ; 5:
tag (Site Health Debug Section); 6. ; */
esc_html__( 'You are directly connected to %1$sElasticPress.io%2$s, ensuring the most performant Autosuggest experience. %3$sLearn more about what this means%4$s or %5$sclick here for debug information%6$s.', 'elasticpress' ),
'
',
'',
'
',
'',
'
',
''
);
} else {
printf(
/* translators: 1:
tag (ElasticPress.io); 2. ; 3:
tag (KB article); 4. ; */
esc_html__( 'You are directly connected to %1$sElasticPress.io%2$s, ensuring the most performant Autosuggest experience. %1$sLearn more about what this means%2$s.', 'elasticpress' ),
'
',
'',
'
',
''
);
if ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || ( defined( 'WP_EP_DEBUG' ) && WP_EP_DEBUG ) ) {
?>
[],
'postStatus' => [],
'searchFields' => [],
'returnFields' => '',
]
);
$fields = [
wp_sprintf( esc_html__( 'Post Types: %l', 'elasticpress' ), $allowed_params['postTypes'] ),
wp_sprintf( esc_html__( 'Post Status: %l', 'elasticpress' ), $allowed_params['postStatus'] ),
wp_sprintf( esc_html__( 'Search Fields: %l', 'elasticpress' ), $allowed_params['searchFields'] ),
wp_sprintf( esc_html__( 'Returned Fields: %s', 'elasticpress' ), var_export( $allowed_params['returnFields'], true ) ), // phpcs:ignore
];
echo implode( '
', $fields ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
?>
epio_retrieve_autosuggest_allowed();
if ( is_wp_error( $allowed_params ) || ( isset( $allowed_params['status'] ) && 200 !== $allowed_params['status'] ) ) {
$allowed_params = [];
break;
}
if ( empty( $allowed_params ) ) {
$this->epio_send_autosuggest_public_request( true );
}
}
return $allowed_params;
}
/**
* Add Autosuggest info for EP.io Users in Health Check Info Screen.
*
* @since 3.5.x
* @param array $debug_info Debug Info set so far.
* @return array
*/
public function epio_autosuggest_health_check_info( $debug_info ) {
if ( ! Utils\is_epio() ) {
return $debug_info;
}
$debug_info['epio_autosuggest'] = array(
'label' => esc_html__( 'ElasticPress.io - Autosuggest', 'elasticpress' ),
'fields' => [],
);
$allowed_params = $this->epio_autosuggest_set_and_get();
if ( empty( $allowed_params ) ) {
return $debug_info;
}
$allowed_params = wp_parse_args(
$allowed_params,
[
'postTypes' => [],
'postStatus' => [],
'searchFields' => [],
'returnFields' => '',
]
);
$fields = [
'Post Types' => wp_sprintf( esc_html__( '%l', 'elasticpress' ), $allowed_params['postTypes'] ),
'Post Status' => wp_sprintf( esc_html__( '%l', 'elasticpress' ), $allowed_params['postStatus'] ),
'Search Fields' => wp_sprintf( esc_html__( '%l', 'elasticpress' ), $allowed_params['searchFields'] ),
'Returned Fields' => wp_sprintf( esc_html( var_export( $allowed_params['returnFields'], true ) ) ), // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
];
foreach ( $fields as $label => $value ) {
$debug_info['epio_autosuggest']['fields'][ sanitize_title( $label ) ] = [
'label' => $label,
'value' => $value,
'private' => true,
];
}
return $debug_info;
}
}