本文整理匯總了PHP中WPSEO_Frontend::author方法的典型用法代碼示例。如果您正苦於以下問題:PHP WPSEO_Frontend::author方法的具體用法?PHP WPSEO_Frontend::author怎麽用?PHP WPSEO_Frontend::author使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WPSEO_Frontend
的用法示例。
在下文中一共展示了WPSEO_Frontend::author方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: test_author
/**
* @covers WPSEO_Frontend::author
*/
public function test_author()
{
$this->assertFalse(self::$class_instance->author());
// create and go to post
$author_id = $this->factory->user->create(array('role' => 'administrator'));
$post_id = $this->factory->post->create(array('post_author' => $author_id));
$this->go_to(get_permalink($post_id));
// post type default not set
$this->assertFalse(self::$class_instance->author());
// post type default set but author meta not set
self::$class_instance->options['noauthorship-post'] = false;
$this->assertFalse(self::$class_instance->author());
// post author meta, but not set
WPSEO_Meta::set_value('authorship', 'always', $post_id);
$this->assertFalse(self::$class_instance->author());
// set author meta
$gplus = 'https://plus.google.com/+JoostdeValk';
add_user_meta($author_id, 'googleplus', $gplus);
$expected = '<link rel="author" href="' . esc_url($gplus) . '"/>' . "\n";
// post author meta and user meta set
$this->assertTrue(self::$class_instance->author());
$this->expectOutput($expected);
// post type default and user meta set
WPSEO_Meta::set_value('authorship', '-', $post_id);
$this->assertTrue(self::$class_instance->author());
$this->expectOutput($expected);
}