/** * Save post hook * Called when WP saves a post and updates the search index * * @param string * @return void **/ function save_post($id) { global $wpdb; // Get full details for the post $options = $this->get_options(); $post = $wpdb->get_row("SELECT {$wpdb->posts}.*,{$wpdb->users}.user_login,{$wpdb->users}.user_nicename,{$wpdb->users}.display_name FROM {$wpdb->posts} LEFT JOIN {$wpdb->users} ON {$wpdb->posts}.post_author={$wpdb->users}.ID WHERE {$wpdb->posts}.ID=" . $id); $this->disable_filters($options['disabled_filters']); // If this isnt a revision if ($post->post_type != 'revision') { // Create search engine and search spider include_once dirname(__FILE__) . '/models/spider.php'; include_once dirname(__FILE__) . '/models/search-engine.php'; $spider = new SearchSpider($options); $engine = SearchEngine::get_engine($options, $options['search_engine']); $engine->remove($post->ID, 'post'); if ($spider->is_allowed($post)) { $engine->store($post->ID, $spider->gather_for_post($post), $post); } $engine->flush(); } }