本文整理汇总了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));
}