/** * Get all sites, count indexes * * @return array total index count with last blog id to manipulate blog with an index */ function ep_count_indexes() { $sites = ep_get_sites(); $count_indexes = 0; foreach ($sites as $site) { if ($index_name = ep_get_index_name($site['blog_id'])) { if (ep_index_exists($index_name)) { $count_indexes++; $last_blog_id_with_index = $site['blog_id']; } } } return array('total_indexes' => $count_indexes, 'last_blog_id_with_index' => $last_blog_id_with_index); }
public function action_delete_blog_from_index($blog_id) { if (ep_index_exists(ep_get_index_name($blog_id)) && !apply_filters('ep_keep_index', false)) { ep_delete_index(ep_get_index_name($blog_id)); } }
/** * Test index_exists helper function */ public function testIndexExists() { $sites = ep_get_sites(); $first_site_index = ep_get_index_name($sites[0]['blog_id']); $index_should_exist = ep_index_exists($first_site_index); $index_should_not_exist = ep_index_exists($first_site_index . 2); $this->assertTrue($index_should_exist); $this->assertFalse($index_should_not_exist); }