本文整理匯總了PHP中Indexer::_build_document方法的典型用法代碼示例。如果您正苦於以下問題:PHP Indexer::_build_document方法的具體用法?PHP Indexer::_build_document怎麽用?PHP Indexer::_build_document使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Indexer
的用法示例。
在下文中一共展示了Indexer::_build_document方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testBuildDocument
public function testBuildDocument()
{
update_option('fields', array('field1' => 1, 'post_date' => 1));
register_post_type('post');
register_taxonomy('tax1', 'post');
register_taxonomy('tax2', 'post');
wp_insert_term('Term 1', 'tax1', array('slug' => 'term1'));
wp_insert_term('Term 2', 'tax1', array('slug' => 'term2', 'parent' => 1));
wp_insert_term('Term 3', 'tax1', array('slug' => 'term3', 'parent' => 2));
wp_insert_term('Term 4', 'tax2', array('slug' => 'term4'));
wp_insert_term('Term 5', 'tax2', array('slug' => 'term5'));
wp_insert_term('Term 6', 'tax2', array('slug' => 'term6', 'parent' => 1));
wp_set_object_terms(2, array(3), 'tax1');
wp_set_object_terms(2, array(2, 3), 'tax2');
$post = (object) array('field1' => 'value1', 'ID' => 2, 'post_date' => '10/24/1988 00:00:00 CST', 'post_type' => 'post');
$tz = date_default_timezone_get();
date_default_timezone_set('America/Chicago');
$document = Indexer::_build_document($post);
date_default_timezone_set($tz);
$this->assertEquals(array('field1' => 'value1', 'post_date' => '1988-10-24T01:00:00-05:00', 'tax1' => array('term3', 'term2', 'term1'), 'tax2' => array('term5', 'term6', 'term4'), 'tax1_name' => array('Term 3', 'Term 2', 'Term 1'), 'tax2_name' => array('Term 5', 'Term 6', 'Term 4'), 'blog_id' => 1), $document);
}
示例2: testBuildDocumentOmitsEmptyCustomFields
public function testBuildDocumentOmitsEmptyCustomFields()
{
update_option('fields', array());
update_option('meta_fields', array('name' => 1, 'empty_field' => 1));
register_post_type('post');
$post = (object) array('ID' => 2, 'post_type' => 'post');
add_post_meta($post->ID, 'name', 'RubyOnRails');
$document = Indexer::_build_document($post);
$this->assertEquals(array('name' => 'RubyOnRails', 'blog_id' => 1), $document);
}