本文整理汇总了PHP中Indexer::get_count方法的典型用法代码示例。如果您正苦于以下问题:PHP Indexer::get_count方法的具体用法?PHP Indexer::get_count怎么用?PHP Indexer::get_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Indexer
的用法示例。
在下文中一共展示了Indexer::get_count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetCount
public function testGetCount()
{
global $wp_query;
register_post_type('post');
$this->assertEquals(100, Indexer::get_count());
$this->assertEquals(array('post'), $wp_query->args['post_type']);
$this->assertEquals('publish', $wp_query->args['post_status']);
}
示例2: add_action
<?php
namespace elasticsearch;
add_action('admin_head-toplevel_page_elastic_search', function () {
wp_enqueue_script('es-indexing', plugins_url('/manage-index.js', __FILE__), array('jquery'));
wp_localize_script('es-indexing', 'indexing', array('ajaxurl' => admin_url('admin-ajax.php'), 'total' => Indexer::get_count(), 'perpage' => Indexer::per_page()));
});
add_filter('nhp-opts-saved-text-elasticsearch', function ($default) {
if (get_transient('es-wiped') == 1) {
return '<strong>The index has been wiped.</strong>';
delete_transient('es-wiped');
}
if (get_transient('es-indexed') == 1) {
return '<strong>The index has been populated.</strong>';
delete_transient('es-indexed');
}
return $default;
});
add_action('nhp-opts-options-validate-elasticsearch', function () {
if (isset($_POST['wipe']) && $_POST['wipe']) {
try {
Indexer::clear();
set_transient('es-wiped', 1, 30);
} catch (\Exception $ex) {
$errors = get_transient('nhp-opts-errors-elasticsearch');
$errors[] = array('section_id' => 'index');
set_transient('nhp-opts-errors-elasticsearch', $errors, 1000);
set_transient('es-wiped-error', $ex->getMessage(), 30);
}
}