og_title() public method

Outputs the SEO title as OpenGraph title.
public og_title ( boolean $echo = true ) : string | boolean
$echo boolean Whether or not to echo the output.
return string | boolean
コード例 #1
0
 /**
  * @covers WPSEO_OpenGraph::og_title
  */
 public function test_og_title()
 {
     // create and go to post
     $post_id = $this->factory->post->create();
     $this->go_to(get_permalink($post_id));
     $expected_title = self::$class_instance->title('');
     $expected_html = '<meta property="og:title" content="' . $expected_title . '" />' . "\n";
     $this->assertTrue(self::$class_instance->og_title());
     $this->expectOutput($expected_html);
     $this->assertEquals(self::$class_instance->og_title(false), $expected_title);
 }
コード例 #2
0
 /**
  * Tests static page set as posts page
  */
 public function test_static_posts_page()
 {
     $post_id = $this->factory->post->create(array('post_title' => 'front-page', 'post_type' => 'page'));
     update_option('show_on_front', 'page');
     update_option('page_on_front', $post_id);
     $post_id = $this->factory->post->create(array('post_title' => 'blog-page', 'post_type' => 'page'));
     update_option('page_for_posts', $post_id);
     $this->go_to(get_permalink($post_id));
     WPSEO_Meta::set_value('title', 'SEO title', $post_id);
     $title = self::$class_instance->og_title(false);
     $this->assertEquals('SEO title', $title);
     WPSEO_Meta::set_value('opengraph-title', 'OG title', $post_id);
     $title = self::$class_instance->og_title(false);
     $this->assertEquals('OG title', $title);
     WPSEO_Meta::set_value('metadesc', 'SEO description', $post_id);
     $description = self::$class_instance->description(false);
     $this->assertEquals('SEO description', $description);
     WPSEO_Meta::set_value('opengraph-description', 'OG description', $post_id);
     $description = self::$class_instance->description(false);
     $this->assertEquals('OG description', $description);
 }