Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/Yoast/wordpress-seo
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Apr 4, 2014
2 parents c726c61 + 2f37fe3 commit aae0b04
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 41 deletions.
4 changes: 4 additions & 0 deletions admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ function add_action_link( $links, $file ) {
$premium_link = '<a href="https://yoast.com/wordpress/plugins/seo-premium/support/#utm_source=wordpress-seo-settings-link&utm_medium=text-link&utm_campaign=support-link">' . __( 'Premium Support', 'wordpress-seo' ) .'</a>';
array_unshift( $links, $premium_link );

// add link to docs
$faq_link = '<a href="https://yoast.com/wordpress/plugins/seo/faq/">' . __( 'FAQ', 'wordpress-seo' ) .'</a>';
array_unshift( $links, $faq_link );

return $links;
}

Expand Down
27 changes: 25 additions & 2 deletions frontend/class-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -951,15 +951,21 @@ private function adjacent_rel_link( $rel, $url, $page, $incl_pagination_base ) {

/**
* Output the rel=publisher code on every page of the site.
* @return boolean Boolean indicating whether the publisher link was printed
*/
public function publisher() {

if ( $this->options['plus-publisher'] !== '' ) {
echo '<link rel="publisher" href="' . esc_url( $this->options['plus-publisher'] ) . '"/>' . "\n";
return true;
}

return false;
}

/**
* Outputs the rel=author
* @return boolean Boolean indiciting whether the autor link was printed
*/
public function author() {
global $post;
Expand Down Expand Up @@ -994,7 +1000,10 @@ public function author() {

if ( is_string( $gplus ) && $gplus !== '' ) {
echo '<link rel="author" href="' . esc_url( $gplus ) . '"/>' . "\n";
return true;
}

return false;
}

/**
Expand Down Expand Up @@ -1152,20 +1161,23 @@ public function metadesc( $echo = true ) {
/**
* Based on the redirect meta value, this function determines whether it should redirect the current post / page.
*
* @return mixed
* @return boolean
*/
function page_redirect() {
if ( is_singular() ) {
global $post;
if ( ! isset( $post ) || ! is_object( $post ) ) {
return;
return false;
}

$redir = WPSEO_Meta::get_value( 'redirect', $post->ID );
if ( $redir !== '' ) {
wp_redirect( $redir, 301 );
exit;
}
}

return false;
}

/**
Expand All @@ -1180,11 +1192,16 @@ public function noindex_page() {
* to follow the links in the object at the URL.
*
* @since 1.1.7
* @return boolean Boolean indicating whether the noindex header was sent
*/
public function noindex_feed() {

if ( ( is_feed() || is_robots() ) && headers_sent() === false ) {
header( 'X-Robots-Tag: noindex,follow', true );
return true;
}

return false;
}

/**
Expand All @@ -1200,6 +1217,7 @@ public function nofollow_link( $input ) {

/**
* When certain archives are disabled, this redirects those to the homepage.
* @return boolean False when no redirect was triggered
*/
function archive_redirect() {
global $wp_query;
Expand All @@ -1212,19 +1230,24 @@ function archive_redirect() {
wp_safe_redirect( get_bloginfo( 'url' ), 301 );
exit;
}

return false;
}

/**
* If the option to redirect attachments to their parent is checked, this performs the redirect.
*
* An extra check is done for when the attachment has no parent.
* @return boolean False when no redirect was triggered
*/
function attachment_redirect() {
global $post;
if ( is_attachment() && ( ( is_object( $post ) && isset( $post->post_parent ) ) && ( is_numeric( $post->post_parent ) && $post->post_parent != 0 ) ) ) {
wp_safe_redirect( get_permalink( $post->post_parent ), 301 );
exit;
}

return false;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions frontend/class-opengraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,11 @@ public function description( $echo = true ) {

if ( is_singular() ) {
$ogdesc = WPSEO_Meta::get_value( 'opengraph-description' );

// Replace WP SEO Variables
$ogdesc = wpseo_replace_vars( $ogdesc, get_post() );

// Use metadesc if $ogdesc is empty
if ( $ogdesc === '' ) {
$ogdesc = $this->metadesc( false );
}
Expand Down
5 changes: 3 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ License URI: http://www.gnu.org/licenses/gpl.html
Tags: seo, SEO, google, meta, meta description, search engine optimization, xml sitemap, xml sitemaps, google sitemap, sitemap, sitemaps, robots meta, rss, rss footer, yahoo, bing, news sitemaps, XML News Sitemaps, WordPress SEO, WordPress SEO by Yoast, yoast, multisite, canonical, nofollow, noindex, keywords, meta keywords, description, webmaster tools, google webmaster tools, seo pack
Requires at least: 3.5
Tested up to: 3.8.1
Stable tag: 1.5.2.5
Stable tag: 1.5.2.6

Improve your WordPress SEO: Write better content and have a fully optimized WordPress site using the WordPress SEO plugin by Yoast.

Expand Down Expand Up @@ -109,7 +109,7 @@ You'll find the [FAQ on Yoast.com](https://yoast.com/wordpress/plugins/seo/faq/)

== Changelog ==

= Trunk =
= 1.5.2.6 =

* Bugfixes
* Fixed Open Graph Facebook Debubber Tags/Categories Issue, tags/categories are now grouped into one metatag - props [lgrandicelli](https://github.com/lgrandicelli).
Expand All @@ -118,6 +118,7 @@ You'll find the [FAQ on Yoast.com](https://yoast.com/wordpress/plugins/seo/faq/)
* Fixed a bug that caused the 'Plugins activated' message to be removed by the robots error message - props [andyexeter](https://github.com/andyexeter).
* Fix white screen/blog down issues caused by some webhosts actively disabling the PHP ctype extension - props [Jrf](http://profiles.wordpress.org/jrf).
* Fixes Metabox Social tab media uploader not working on custom post types which don't use media as reported by [Drethic](https://github.com/Drethic) in [issue #911](https://github.com/Yoast/wordpress-seo/issues/911) - props [Jrf](http://profiles.wordpress.org/jrf).
* Fixed vars not being replaced in OG description tag.

* Enhancement
* Fix PHP warnings when post_type is an array.
Expand Down
4 changes: 2 additions & 2 deletions tests/framework/class-wpseo-unit-test-case.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ protected function go_to_home() {

/**
* @param string $string
* @param string $function
* @param mixed $function
*/
protected function expectOutput( $string, $function ) {
protected function expectOutput( $string, $function = null ) {
$output = ob_get_contents();
ob_clean();
$this->assertEquals( $output, $string );
Expand Down
33 changes: 15 additions & 18 deletions tests/test-class-opengraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,16 @@ public function test_options_not_empty() {
public function test_og_tag() {

// there should be no output when $content is empty
$this->expectOutputString( '' );
$this->assertFalse( $this->class_instance->og_tag( 'property', '' ) );
$this->assertFalse( $this->class_instance->og_tag( 'property', '' ) );
$this->expectOutput( '' );

// true when $content is not empty
$this->expectOutputString( '<meta property="property" content="content" />' . "\n" );
$this->assertTrue( $this->class_instance->og_tag( 'property', 'content' ) );
ob_clean();
$this->expectOutput( '<meta property="property" content="content" />' . "\n" );

// test escaping
$this->expectOutputString( '<meta property="property &quot;with quotes&quot;" content="content &quot;with quotes&quot;" />' . "\n" );
$this->assertTrue( $this->class_instance->og_tag( 'property "with quotes"', 'content "with quotes"' ) );

$this->expectOutput( '<meta property="property &quot;with quotes&quot;" content="content &quot;with quotes&quot;" />' . "\n" );
}

/**
Expand All @@ -114,8 +112,8 @@ public function test_article_author_facebook() {
add_user_meta( $author, 'facebook', 'facebook_author' );

// test final output
$this->expectOutputString( '<meta property="article:author" content="facebook_author" />' . "\n" );
$this->assertTrue( $this->class_instance->article_author_facebook() );
$this->expectOutput( '<meta property="article:author" content="facebook_author" />' . "\n" );

// test not on singular page
$this->go_to_home();
Expand All @@ -133,8 +131,8 @@ public function test_website_facebook() {
$this->class_instance->options['facebook_site'] = 'http://facebook.com/mysite/';

// test output
$this->expectOutputString( '<meta property="article:publisher" content="http://facebook.com/mysite/" />' . "\n" );
$this->assertTrue( $this->class_instance->website_facebook() );
$this->expectOutput( '<meta property="article:publisher" content="http://facebook.com/mysite/" />' . "\n" );
}

public function test_site_owner() {
Expand All @@ -144,11 +142,11 @@ public function test_site_owner() {
}

public function test_og_title() {
$expected_title = "Sample Post - Test Blog";
$expected_title = $this->class_instance->title( '' );
$expected_html = '<meta property="og:title" content="'.$expected_title.'" />' . "\n";

$this->expectOutputString( $expected_html );
$this->assertTrue( $this->class_instance->og_title() );
$this->expectOutput( $expected_html );

$this->assertEquals( $this->class_instance->og_title( false ), $expected_title );

Expand All @@ -157,8 +155,8 @@ public function test_og_title() {
public function test_url() {
$expected_url = get_permalink( $this->post_id );

$this->expectOutputString( '<meta property="og:url" content="' . $expected_url . '" />' . "\n" );
$this->assertTrue( $this->class_instance->url() );
$this->expectOutput( '<meta property="og:url" content="' . $expected_url . '" />' . "\n" );
}

public function test_type() {
Expand All @@ -181,8 +179,8 @@ public function test_image_output() {
$img_url = home_url('absolute-image.jpg');

// test with absolute image
$this->expectOutputString( '<meta property="og:image" content="' . $img_url . '" />' . "\n" );
$this->assertTrue( $this->class_instance->image_output( $img_url ) );
$this->expectOutput( '<meta property="og:image" content="' . $img_url . '" />' . "\n" );

// do not output same image twice
$this->assertFalse( $this->class_instance->image_output( $img_url ) );
Expand All @@ -191,8 +189,8 @@ public function test_image_output() {
ob_clean();
$relative_img_url = '/relative-image.jpg';
$absolute_img_url = home_url( $relative_img_url );
$this->expectOutputString( '<meta property="og:image" content="' . $absolute_img_url . '" />' . "\n" );
$this->assertTrue( $this->class_instance->image_output( $relative_img_url ) );
$this->expectOutput( '<meta property="og:image" content="' . $absolute_img_url . '" />' . "\n" );
}

public function test_tags() {
Expand All @@ -205,8 +203,8 @@ public function test_tags() {
$expected_tags = '<meta property="article:tag" content="Tag1" />' . "\n" . '<meta property="article:tag" content="Tag2" />' . "\n";

// test again, this time with tags
$this->expectOutputString( $expected_tags );
$this->assertTrue( $this->class_instance->tags() );
$this->expectOutput( $expected_tags );

// not singular, return false
$this->go_to_home();
Expand All @@ -219,8 +217,8 @@ public function test_tags() {
public function test_category() {

// Test category
$this->expectOutputString( '<meta property="article:section" content="WordPress SEO" />' . "\n" );
$this->assertTrue( $this->class_instance->category() );
$this->expectOutput( '<meta property="article:section" content="WordPress SEO" />' . "\n" );

// not singular, should return false
$this->go_to_home();
Expand All @@ -242,8 +240,8 @@ public function test_publish_date() {
// test published_time tags output
$published_time = get_the_date( 'c' );
$published_output = '<meta property="article:published_time" content="' . $published_time . '" />' . "\n";
$this->expectOutputString( $published_output );
$this->assertTrue( $this->class_instance->publish_date() );
$this->expectOutput( $published_output );

ob_clean();

Expand All @@ -256,9 +254,8 @@ public function test_publish_date() {
// test modified tags output
$modified_time = get_the_modified_date( 'c' );
$modified_output = '<meta property="article:modified_time" content="' . $modified_time . '" />' . "\n" . '<meta property="og:updated_time" content="' . $modified_time . '" />' . "\n";
$this->expectOutputString( $published_output . $modified_output );
$this->assertTrue( $this->class_instance->publish_date() );

$this->expectOutput( $published_output . $modified_output );
}

private function go_to_post() {
Expand Down
Loading

0 comments on commit aae0b04

Please sign in to comment.