/** * Remove a WordPress post or page from search results when it is moved to the trash * @param $post_id int */ public function TrashPost($post_id) { require_once "search/mysql-search-indexer.class.php"; require_once "data/mysql-connection.class.php"; $search = new MySqlSearchIndexer(new MySqlConnection($this->settings->DatabaseHost(), $this->settings->DatabaseUser(), $this->settings->DatabasePassword(), $this->settings->DatabaseName())); $post = get_post($post_id); if ($post and $post->post_type == 'post') { $search->DeleteFromIndexById("post" . $post_id); } else { if ($post and $post->post_type == 'page') { $search->DeleteFromIndexById("page" . $post_id); } } }