本文整理匯總了PHP中WPSEO_Frontend::robots_for_single_post方法的典型用法代碼示例。如果您正苦於以下問題:PHP WPSEO_Frontend::robots_for_single_post方法的具體用法?PHP WPSEO_Frontend::robots_for_single_post怎麽用?PHP WPSEO_Frontend::robots_for_single_post使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WPSEO_Frontend
的用法示例。
在下文中一共展示了WPSEO_Frontend::robots_for_single_post方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: test_robots_for_single_post
/**
* @covers WPSEO_Frontend::robots_for_single_post
*/
public function test_robots_for_single_post()
{
// create and go to post
$post_id = $this->factory->post->create();
$this->go_to(get_permalink($post_id));
$robots = array('index' => 'index', 'follow' => 'follow', 'other' => array());
$expected = $robots;
// test noindex
WPSEO_Meta::set_value('meta-robots-noindex', '1', $post_id);
$expected['index'] = 'noindex';
$this->assertEquals($expected, self::$class_instance->robots_for_single_post($robots, $post_id));
// test nofollow
WPSEO_Meta::set_value('meta-robots-nofollow', 1, $post_id);
$expected['follow'] = 'nofollow';
$this->assertEquals($expected, self::$class_instance->robots_for_single_post($robots, $post_id));
// test noodp with default meta-robots-adv
self::$class_instance->options['noodp'] = true;
$expected['other'] = array('noodp');
$this->assertEquals($expected, self::$class_instance->robots_for_single_post($robots, $post_id));
// test noydir with default meta-robots-adv
self::$class_instance->options['noydir'] = true;
$expected['other'] = array('noodp', 'noydir');
$this->assertEquals($expected, self::$class_instance->robots_for_single_post($robots, $post_id));
// test meta-robots adv noodp and nosnippet
WPSEO_Meta::set_value('meta-robots-adv', 'noodp,nosnippet', $post_id);
$expected['other'] = array('noodp', 'nosnippet');
$this->assertEquals($expected, self::$class_instance->robots_for_single_post($robots, $post_id));
WPSEO_Meta::set_value('meta-robots-noindex', '2', $post_id);
$expected['index'] = 'index';
$this->assertEquals($expected, self::$class_instance->robots_for_single_post($robots, $post_id));
}