public function parse_api_response($response)
{
if (null === $response) {
return array('status' => false, 'msg' => esc_html__('Invalid response from ElasticPress server. Please contact your administrator.'));
} elseif (isset($response->error) && (is_string($response->error) && stristr($response->error, 'IndexMissingException') || isset($response->error->reason) && stristr($response->error->reason, 'no such index'))) {
if (is_multisite()) {
$error = __('Site not indexed. <p>Please run: <code>wp elasticpress index --setup --network-wide</code> using WP-CLI. Or use the index button on the left of this screen.</p>', 'elasticpress');
} else {
$error = __('Site not indexed. <p>Please run: <code>wp elasticpress index --setup</code> using WP-CLI. Or use the index button on the left of this screen.</p>', 'elasticpress');
}
return array('status' => false, 'msg' => $error);
}
return array('status' => true, 'data' => $response->_all->primaries->indexing);
}