Edit File by line
/home/barbar84/www/wp-conte.../plugins/wordpres.../src/generato.../schema
File: organization.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Generators\Schema;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Config\Schema_IDs;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Returns schema Organization data.
[7] Fix | Delete
*/
[8] Fix | Delete
class Organization extends Abstract_Schema_Piece {
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Determines whether an Organization graph piece should be added.
[12] Fix | Delete
*
[13] Fix | Delete
* @return bool
[14] Fix | Delete
*/
[15] Fix | Delete
public function is_needed() {
[16] Fix | Delete
return $this->context->site_represents === 'company';
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Returns the Organization Schema data.
[21] Fix | Delete
*
[22] Fix | Delete
* @return array The Organization schema.
[23] Fix | Delete
*/
[24] Fix | Delete
public function generate() {
[25] Fix | Delete
$logo_schema_id = $this->context->site_url . Schema_IDs::ORGANIZATION_LOGO_HASH;
[26] Fix | Delete
[27] Fix | Delete
if ( $this->context->company_logo_meta ) {
[28] Fix | Delete
$logo = $this->helpers->schema->image->generate_from_attachment_meta( $logo_schema_id, $this->context->company_logo_meta, $this->context->company_name );
[29] Fix | Delete
}
[30] Fix | Delete
else {
[31] Fix | Delete
$logo = $this->helpers->schema->image->generate_from_attachment_id( $logo_schema_id, $this->context->company_logo_id, $this->context->company_name );
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
return [
[35] Fix | Delete
'@type' => 'Organization',
[36] Fix | Delete
'@id' => $this->context->site_url . Schema_IDs::ORGANIZATION_HASH,
[37] Fix | Delete
'name' => $this->helpers->schema->html->smart_strip_tags( $this->context->company_name ),
[38] Fix | Delete
'url' => $this->context->site_url,
[39] Fix | Delete
'sameAs' => $this->fetch_social_profiles(),
[40] Fix | Delete
'logo' => $logo,
[41] Fix | Delete
'image' => [ '@id' => $logo_schema_id ],
[42] Fix | Delete
];
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* Retrieve the social profiles to display in the organization schema.
[47] Fix | Delete
*
[48] Fix | Delete
* @return array An array of social profiles.
[49] Fix | Delete
*/
[50] Fix | Delete
private function fetch_social_profiles() {
[51] Fix | Delete
$profiles = [];
[52] Fix | Delete
$social_profiles = [
[53] Fix | Delete
'facebook_site',
[54] Fix | Delete
'instagram_url',
[55] Fix | Delete
'linkedin_url',
[56] Fix | Delete
'myspace_url',
[57] Fix | Delete
'youtube_url',
[58] Fix | Delete
'pinterest_url',
[59] Fix | Delete
'wikipedia_url',
[60] Fix | Delete
];
[61] Fix | Delete
foreach ( $social_profiles as $profile ) {
[62] Fix | Delete
$social_profile = $this->helpers->options->get( $profile, '' );
[63] Fix | Delete
if ( $social_profile !== '' ) {
[64] Fix | Delete
$profiles[] = \urldecode( $social_profile );
[65] Fix | Delete
}
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
$twitter = $this->helpers->options->get( 'twitter_site', '' );
[69] Fix | Delete
if ( $twitter !== '' ) {
[70] Fix | Delete
$profiles[] = 'https://twitter.com/' . $twitter;
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Filter: 'wpseo_schema_organization_social_profiles' - Allows filtering social profiles for the
[75] Fix | Delete
* represented organization.
[76] Fix | Delete
*
[77] Fix | Delete
* @api string[] $profiles
[78] Fix | Delete
*/
[79] Fix | Delete
$profiles = \apply_filters( 'wpseo_schema_organization_social_profiles', $profiles );
[80] Fix | Delete
[81] Fix | Delete
return $profiles;
[82] Fix | Delete
}
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function