当前位置: 首页>>代码示例>>PHP>>正文


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怎么用?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));
 }
开发者ID:michalvittek,项目名称:wordpress-seo,代码行数:34,代码来源:test-class-wpseo-frontend.php


注:本文中的WPSEO_Frontend::robots_for_single_post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。