Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/11.3' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
IreneStr committed May 22, 2019
2 parents e1edb75 + 785f2f0 commit 1f1fad2
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 86 deletions.
28 changes: 0 additions & 28 deletions admin/taxonomy/class-taxonomy-metabox.php
Expand Up @@ -62,22 +62,8 @@ public function display() {
printf( '<div id="wpseo_meta" class="postbox yoast wpseo-taxonomy-metabox-postbox"><h2><span>%1$s</span></h2>', $product_title );

echo '<div class="inside">';

$helpcenter_tab = new WPSEO_Option_Tab(
'tax-metabox',
__( 'Meta box', 'wordpress-seo' ),
array( 'video_url' => WPSEO_Shortlinker::get( 'https://yoa.st/metabox-taxonomy-screencast' ) )
);

$helpcenter = new WPSEO_Help_Center( 'tax-metabox', $helpcenter_tab, WPSEO_Utils::is_yoast_seo_premium() );
$helpcenter->localize_data();
$helpcenter->mount();

echo '<div id="taxonomy_overall"></div>';

if ( ! defined( 'WPSEO_PREMIUM_FILE' ) ) {
echo $this->get_buy_premium_link();
}

echo '<div class="wpseo-metabox-content">';
echo '<div class="wpseo-metabox-sidebar"><ul>';
Expand Down Expand Up @@ -224,18 +210,4 @@ private function create_tab( $name, $network, $icon, $label ) {
private function has_single_social_tab() {
return ( WPSEO_Options::get( 'opengraph' ) === false || WPSEO_Options::get( 'twitter' ) === false );
}

/**
* Returns a link to activate the Buy Premium tab.
*
* @return string
*/
private function get_buy_premium_link() {
return sprintf(
'<div class="wpseo-metabox-buy-premium"><a target="_blank" href="%1$s"><span class="dashicons dashicons-star-filled wpseo-buy-premium"></span>%2$s%3$s</a></div>',
esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/3hh' ) ),
esc_html__( 'Go Premium', 'wordpress-seo' ),
WPSEO_Admin_Utils::get_new_tab_message()
);
}
}
35 changes: 27 additions & 8 deletions frontend/schema/class-schema-author.php
Expand Up @@ -20,15 +20,22 @@ class WPSEO_Schema_Author extends WPSEO_Schema_Person implements WPSEO_Graph_Pie
*/
private $context;

/**
* The Schema type we use for this class.
*
* @var string[]
*/
protected $type = array( 'Person' );

/**
* WPSEO_Schema_Author constructor.
*
* @param WPSEO_Schema_Context $context A value object with context variables.
*/
public function __construct( WPSEO_Schema_Context $context ) {
parent::__construct( $context );
$this->context = $context;
$this->logo_hash = WPSEO_Schema_IDs::AUTHOR_LOGO_HASH;
$this->context = $context;
$this->image_hash = WPSEO_Schema_IDs::AUTHOR_LOGO_HASH;
}

/**
Expand All @@ -55,14 +62,17 @@ public function is_needed() {
}

/**
* Builds our array of Schema Person data for a given user ID.
*
* @param int $user_id The user ID to use.
* Returns Person Schema data.
*
* @return array An array of Schema Person data.
* @return bool|array Person data on success, false on failure.
*/
protected function build_person_data( $user_id ) {
$data = parent::build_person_data( $user_id );
public function generate() {
$user_id = $this->determine_user_id();
if ( ! $user_id ) {
return false;
}

$data = $this->build_person_data( $user_id );

// If this is an author page, the Person object is the main object, so we set it as such here.
if ( is_author() ) {
Expand Down Expand Up @@ -127,4 +137,13 @@ protected function determine_user_id() {
protected function determine_schema_id( $user_id ) {
return get_author_posts_url( $user_id ) . WPSEO_Schema_IDs::AUTHOR_HASH;
}

/**
* Gets the Schema type we use for this class.
*
* @return string[] The schema type.
*/
public static function get_type() {
return self::$type;
}
}
75 changes: 49 additions & 26 deletions frontend/schema/class-schema-context.php
Expand Up @@ -112,53 +112,76 @@ public function __construct() {
* Builds all the required data for the context object.
*/
private function build_data() {
$this->breadcrumbs_enabled = current_theme_supports( 'yoast-seo-breadcrumbs' );
if ( ! $this->breadcrumbs_enabled ) {
$this->breadcrumbs_enabled = WPSEO_Options::get( 'breadcrumbs-enable', false );
}

// Page level variables.
$front = WPSEO_Frontend::get_instance();
$this->canonical = $front->canonical( false, false, true );
$this->title = $front->title( '' );
$this->description = $front->metadesc( false );
$this->id = get_queried_object_id();

$this->site_name = $this->set_site_name();
$this->site_represents = WPSEO_Options::get( 'company_or_person', '' );
$this->site_url = trailingslashit( WPSEO_Utils::home_url() );
// Site level variables.
$this->site_name = $this->set_site_name();
$this->site_url = trailingslashit( WPSEO_Utils::home_url() );

if ( $this->site_represents === 'company' ) {
$this->company_name = WPSEO_Options::get( 'company_name' );
}
$this->set_breadcrumbs_variables();
$this->set_site_represents_variables();
$this->set_site_represents_reference();
}

if ( $this->site_represents === 'person' ) {
$this->site_user_id = WPSEO_Options::get( 'company_or_person_user_id', false );
// Do not use a non-existing user.
if ( $this->site_user_id !== false && get_user_by( 'id', $this->site_user_id ) === false ) {
$this->site_represents = false;
}
/**
* Retrieves the site's name from settings.
*
* @return string
*/
private function set_site_name() {
if ( '' !== WPSEO_Options::get( 'website_name', '' ) ) {
return WPSEO_Options::get( 'website_name' );
}

return get_bloginfo( 'name' );
}

/**
* Sets our site represents reference for easy use.
*/
private function set_site_represents_reference() {
$this->site_represents_reference = false;

if ( $this->site_represents === 'person' ) {
$this->site_represents_reference = array( '@id' => $this->site_url . WPSEO_Schema_IDs::PERSON_HASH );
}

if ( $this->site_represents === 'company' ) {
$this->site_represents_reference = array( '@id' => $this->site_url . WPSEO_Schema_IDs::ORGANIZATION_HASH );
}

$this->id = get_queried_object_id();
}

/**
* Retrieves the site's name from settings.
*
* @return string
* Determines what our site represents, and grabs their values.
*/
private function set_site_name() {
if ( '' !== WPSEO_Options::get( 'website_name', '' ) ) {
return WPSEO_Options::get( 'website_name' );
private function set_site_represents_variables() {
$this->site_represents = WPSEO_Options::get( 'company_or_person', false );

if ( $this->site_represents === 'company' ) {
$this->company_name = WPSEO_Options::get( 'company_name' );
}

return get_bloginfo( 'name' );
if ( $this->site_represents === 'person' ) {
$this->site_user_id = WPSEO_Options::get( 'company_or_person_user_id', false );
// Do not use a non-existing user.
if ( $this->site_user_id !== false && get_user_by( 'id', $this->site_user_id ) === false ) {
$this->site_represents = false;
}
}
}

/**
* Determines whether the site uses Yoast SEO breadcrumbs.
*/
private function set_breadcrumbs_variables() {
$this->breadcrumbs_enabled = current_theme_supports( 'yoast-seo-breadcrumbs' );
if ( ! $this->breadcrumbs_enabled ) {
$this->breadcrumbs_enabled = WPSEO_Options::get( 'breadcrumbs-enable', false );
}
}
}
73 changes: 54 additions & 19 deletions frontend/schema/class-schema-person.php
Expand Up @@ -17,6 +17,7 @@ class WPSEO_Schema_Person implements WPSEO_Graph_Piece {
* @var WPSEO_Schema_Context
*/
private $context;

/**
* Array of the social profiles we display for a Person.
*
Expand All @@ -35,13 +36,31 @@ class WPSEO_Schema_Person implements WPSEO_Graph_Piece {
'wikipedia',
);

/**
* The Schema type we use for this class.
*
* @var string[]
*/
protected $type = array(
'Person',
'Organization',
);

/**
* The hash used for images.
*
* @var string
*/
protected $image_hash;

/**
* WPSEO_Schema_Person constructor.
*
* @param WPSEO_Schema_Context $context A value object with context variables.
*/
public function __construct( WPSEO_Schema_Context $context ) {
$this->context = $context;
$this->image_hash = WPSEO_Schema_IDs::PERSON_LOGO_HASH;
$this->context = $context;
}

/**
Expand Down Expand Up @@ -127,7 +146,7 @@ protected function get_social_profiles( $user_id ) {
protected function build_person_data( $user_id ) {
$user_data = get_userdata( $user_id );
$data = array(
'@type' => array( 'Person', 'Organization' ),
'@type' => $this->type,
'@id' => $this->determine_schema_id( $user_id ),
'name' => $user_data->display_name,
);
Expand Down Expand Up @@ -155,33 +174,22 @@ protected function build_person_data( $user_id ) {
* @return array $data The Person schema.
*/
protected function add_image( $data, $user_data ) {
$schema_id = $this->context->site_url . WPSEO_Schema_IDs::PERSON_LOGO_HASH;
$schema_id = $this->context->site_url . $this->image_hash;

$data = $this->set_image_from_options( $data, $schema_id );
if ( isset( $data['image'] ) ) {
return $data;
if ( ! isset( $data['image'] ) ) {
$data = $this->set_image_from_avatar( $data, $user_data, $schema_id );
}

// If we don't have an image in our settings, fall back to an avatar, if we're allowed to.
$show_avatars = get_option( 'show_avatars' );
if ( ! $show_avatars ) {
return $data;
}

$url = get_avatar_url( $user_data->user_email );
if ( empty( $url ) ) {
return $data;
if ( is_array( $this->type ) && in_array( 'Organization', $this->type ) ) {
$data['logo'] = array( '@id' => $schema_id );
}

$schema_image = new WPSEO_Schema_Image( $schema_id );
$data['image'] = $schema_image->simple_image_object( $url, $user_data->display_name );
$data['logo'] = array( '@id' => $schema_id );

return $data;
}

/**
* Generate the person avatar / logo from our settings.
* Generate the person image from our settings.
*
* @param array $data The Person schema.
* @param string $schema_id The string used in the `@id` for the schema.
Expand All @@ -199,6 +207,33 @@ private function set_image_from_options( $data, $schema_id ) {
return $data;
}

/**
* Generate the person logo from gravatar.
*
* @param array $data The Person schema.
* @param \WP_User $user_data User data.
* @param string $schema_id The string used in the `@id` for the schema.
*
* @return array $data The Person schema.
*/
private function set_image_from_avatar( $data, $user_data, $schema_id ) {
// If we don't have an image in our settings, fall back to an avatar, if we're allowed to.
$show_avatars = get_option( 'show_avatars' );
if ( ! $show_avatars ) {
return $data;
}

$url = get_avatar_url( $user_data->user_email );
if ( empty( $url ) ) {
return $data;
}

$schema_image = new WPSEO_Schema_Image( $schema_id );
$data['image'] = $schema_image->simple_image_object( $url, $user_data->display_name );

return $data;
}

/**
* Returns the string to use in Schema's `@id`.
*
Expand Down
2 changes: 1 addition & 1 deletion inc/class-my-yoast-api-request.php
Expand Up @@ -24,7 +24,7 @@ class WPSEO_MyYoast_Api_Request {
*/
protected $args = array(
'method' => 'GET',
'timeout' => 1,
'timeout' => 5,
'sslverify' => false,
'headers' => array(
'Accept-Encoding' => '*',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -158,6 +158,6 @@
"yoastseo": "^1.53.0-rc.0"
},
"yoast": {
"pluginVersion": "11.3-RC2"
"pluginVersion": "11.3-RC3"
}
}
3 changes: 2 additions & 1 deletion readme.txt
Expand Up @@ -121,8 +121,9 @@ Bugfixes:
* Fixes a bug where it would no longer be possible to change the user in the Search Appearance settings when the previously selected user had been deleted.

Other:
* Removes help center from edit pages.
* Removes the help center from the metabox.
* Removes redundant `name` attribute from `author` in `Article` schema markup piece.
* Increases the MyYoast API request timeout from 1 to 5 seconds, to give servers with a less optimal connection to our services more room to fetch the data.

= 11.2.1 =
Release Date: May 16th, 2019
Expand Down
2 changes: 1 addition & 1 deletion wp-seo-main.php
Expand Up @@ -15,7 +15,7 @@
* {@internal Nobody should be able to overrule the real version number as this can cause
* serious issues with the options, so no if ( ! defined() ).}}
*/
define( 'WPSEO_VERSION', '11.3-RC2' );
define( 'WPSEO_VERSION', '11.3-RC3' );


if ( ! defined( 'WPSEO_PATH' ) ) {
Expand Down
2 changes: 1 addition & 1 deletion wp-seo.php
Expand Up @@ -8,7 +8,7 @@
*
* @wordpress-plugin
* Plugin Name: Yoast SEO
* Version: 11.3-RC2
* Version: 11.3-RC3
* Plugin URI: https://yoa.st/1uj
* Description: The first true all-in-one SEO solution for WordPress, including on-page content analysis, XML sitemaps and much more.
* Author: Team Yoast
Expand Down

0 comments on commit 1f1fad2

Please sign in to comment.