try { indexDocument($post_id, $document); } catch (APICouldNotIndexDocumentException $e) { echo "<span style=\"color:#dd3d36\">Error indexing document \"{$document->title}\": {$e->getMessage()}</span>\n"; } catch (WordPressCouldNotConnectToAPIException $e) { echo "{$e->getMessage()} {$document->title}."; if (++$attempt < $MAX_ATTEMPTS_PER_POST) { echo " Trying again..."; attemptToIndexDocument($post_id, $document, $attempt); } echo "\n"; } } foreach ($posts_array as $post) { try { $document = DigitalGov_Search_Document::create_from_post($post); attemptToIndexDocument($post->ID, $document, 0); } catch (Exception $e) { echo "Unknown Exception: {$e->getMessage()}"; } continue; } ?> </pre> <p>Indexing complete!</p> <a href="<?php echo esc_url(DigitalGov_Search_Admin::get_page_url()); ?> "><span class="button button-primary"><?php esc_attr_e('Finish', 'digitalgov_search');
public static function delete_post($post_id) { $post = get_post($post_id); $document = DigitalGov_Search_Document::create_from_post($post); $document->unindex($post_id); }