public static function unindex_document($document)
 {
     $url = self::$API_URL . "/{$document->document_id}";
     // headers
     $credentials = DigitalGov_Search::get_handle() . ":" . DigitalGov_Search::get_token();
     $headers = array('headers' => array('Authorization' => 'Basic ' . base64_encode($credentials)), 'method' => 'DELETE');
     return wp_remote_request($url, $headers);
 }
Exemplo n.º 2
0
<?php

global $post;
$indexable = DigitalGov_Search::is_indexable($post);
function selected_option($indexable, $check = true)
{
    if ($indexable == $check) {
        return 'checked';
    }
    return '';
}
?>
<div id="minor">
	<h3>Should this page be indexed?</h3>
	<p><input type="radio" name="index" value="yes" <?php 
echo selected_option($indexable);
?>
> Yes</p>
	<p><input type="radio" name="index" value="no"<?php 
echo selected_option($indexable, false);
?>
> No</p>
</div>
<div id="major-publishing-actions">
	<div id="publishing-actions">
		<input name="save" type="submit" class="button button-primary button-large right" id="publish" value="Update">
	</div>
	<div class="clear"></div>
</div>
?>
" method="post" id="digitalgov_search-enter-api-key" class="right">
		<input type="hidden" name="action" value="enter-key">
                <p><input id="handle" name="handle" type="text" size="15" value="<?php 
echo DigitalGov_Search::get_handle();
?>
" placeholder="i14y drawer handle" class="regular-text code"></p>
                <p><input id="token" name="token" type="text" size="15" value="<?php 
echo DigitalGov_Search::get_token();
?>
" placeholder="secret token" class="regular-text code"></p>
                <input type="submit" name="submit" id="submit" class="button button-secondary" value="<?php 
esc_attr_e('Save Credentials', 'digitalgov_search');
?>
">
		<?php 
if (DigitalGov_Search::credentials_set()) {
    ?>
			<a href="<?php 
    echo esc_url(DigitalGov_Search_Admin::get_page_url('index'));
    ?>
"><span class="button button-primary"><?php 
    esc_attr_e('Index Wordpress', 'digitalgov_search');
    ?>
</span></a>
		<?php 
}
?>
        </form>
</div>
 public static function display_meta_box()
 {
     DigitalGov_Search::view('meta');
 }
Exemplo n.º 5
0
    } catch (WordPressCouldNotConnectToAPIException $e) {
        echo "{$e->getMessage()} {$document->title}.";
        if (++$attempt < $MAX_ATTEMPTS_PER_POST) {
            echo " Trying again...";
            attemptToIndexDocument($post_id, $document, $attempt);
        }
        echo "\n";
    }
}
$args = array('post_type' => 'any', 'post_status' => 'publish', 'posts_per_page' => -1);
$posts_array = get_posts($args);
foreach ($posts_array as $post) {
    try {
        $document = DigitalGov_Search_Document::create_from_post($post);
        deindexDocument($post->ID, $document);
        if (DigitalGov_Search::is_indexable($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 
 public static function display_credentials_error()
 {
     DigitalGov_Search::view('notice');
 }