Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wordpres.../src/generato.../schema
File: author.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Generators\Schema;
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* Returns schema Author data.
[5] Fix | Delete
*/
[6] Fix | Delete
class Author extends Person {
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Determine whether we should return Person schema.
[10] Fix | Delete
*
[11] Fix | Delete
* @return bool
[12] Fix | Delete
*/
[13] Fix | Delete
public function is_needed() {
[14] Fix | Delete
if ( $this->context->indexable->object_type === 'user' ) {
[15] Fix | Delete
return true;
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
if (
[19] Fix | Delete
$this->context->indexable->object_type === 'post'
[20] Fix | Delete
&& $this->helpers->schema->article->is_author_supported( $this->context->indexable->object_sub_type )
[21] Fix | Delete
&& $this->context->schema_article_type !== 'None'
[22] Fix | Delete
) {
[23] Fix | Delete
return true;
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
return false;
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* Returns Person Schema data.
[31] Fix | Delete
*
[32] Fix | Delete
* @return bool|array Person data on success, false on failure.
[33] Fix | Delete
*/
[34] Fix | Delete
public function generate() {
[35] Fix | Delete
$user_id = $this->determine_user_id();
[36] Fix | Delete
if ( ! $user_id ) {
[37] Fix | Delete
return false;
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
$data = $this->build_person_data( $user_id );
[41] Fix | Delete
[42] Fix | Delete
if ( $this->site_represents_current_author() === false ) {
[43] Fix | Delete
$data['@type'] = [ 'Person' ];
[44] Fix | Delete
unset( $data['logo'] );
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
// If this is an author page, the Person object is the main object, so we set it as such here.
[48] Fix | Delete
if ( $this->context->indexable->object_type === 'user' ) {
[49] Fix | Delete
$data['mainEntityOfPage'] = [
[50] Fix | Delete
'@id' => $this->context->main_schema_id,
[51] Fix | Delete
];
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
// If this is a post and the author archives are enabled, set the author archive url as the author url.
[55] Fix | Delete
if ( $this->context->indexable->object_type === 'post' ) {
[56] Fix | Delete
if ( $this->helpers->options->get( 'disable-author' ) !== true ) {
[57] Fix | Delete
$data['url'] = $this->helpers->user->get_the_author_posts_url( $user_id );
[58] Fix | Delete
}
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
return $data;
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* Determines a User ID for the Person data.
[66] Fix | Delete
*
[67] Fix | Delete
* @return bool|int User ID or false upon return.
[68] Fix | Delete
*/
[69] Fix | Delete
protected function determine_user_id() {
[70] Fix | Delete
$user_id = 0;
[71] Fix | Delete
[72] Fix | Delete
if ( $this->context->indexable->object_type === 'post' ) {
[73] Fix | Delete
$user_id = (int) $this->context->post->post_author;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
if ( $this->context->indexable->object_type === 'user' ) {
[77] Fix | Delete
$user_id = $this->context->indexable->object_id;
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
/**
[81] Fix | Delete
* Filter: 'wpseo_schema_person_user_id' - Allows filtering of user ID used for person output.
[82] Fix | Delete
*
[83] Fix | Delete
* @param int|bool $user_id The user ID currently determined.
[84] Fix | Delete
*/
[85] Fix | Delete
$user_id = \apply_filters( 'wpseo_schema_person_user_id', $user_id );
[86] Fix | Delete
[87] Fix | Delete
if ( \is_int( $user_id ) && $user_id > 0 ) {
[88] Fix | Delete
return $user_id;
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
return false;
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* An author should not have an image from options, this only applies to persons.
[96] Fix | Delete
*
[97] Fix | Delete
* @param array $data The Person schema.
[98] Fix | Delete
* @param string $schema_id The string used in the `@id` for the schema.
[99] Fix | Delete
* @param bool $add_hash Whether or not the person's image url hash should be added to the image id.
[100] Fix | Delete
* @param WP_User $user_data User data.
[101] Fix | Delete
*
[102] Fix | Delete
* @return array The Person schema.
[103] Fix | Delete
*/
[104] Fix | Delete
protected function set_image_from_options( $data, $schema_id, $add_hash = false, $user_data = null ) {
[105] Fix | Delete
if ( $this->site_represents_current_author( $user_data ) ) {
[106] Fix | Delete
return parent::set_image_from_options( $data, $schema_id, $add_hash, $user_data );
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
return $data;
[110] Fix | Delete
}
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function