| Current Path : /home/x/b/o/xbodynamge/namtation/wp-content/ |
| Current File : /home/x/b/o/xbodynamge/namtation/wp-content/Graphs.tar |
WebPage/RealEstateListing.php 0000666 00000001244 15114677564 0012177 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\WebPage;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* RealEstateListing graph class.
*
* @since 4.0.0
*/
class RealEstateListing extends WebPage {
/**
* The graph type.
*
* @since 4.0.0
*
* @var string
*/
protected $type = 'RealEstateListing';
/**
* Returns the graph data.
*
* @since 4.0.0
*
* @return array $data The graph data.
*/
public function get() {
$data = parent::get();
$post = aioseo()->helpers->getPost();
if ( ! $post ) {
return $data;
}
$data['datePosted'] = mysql2date( DATE_W3C, $post->post_date, false );
return $data;
}
} WebPage/FAQPage.php 0000666 00000000476 15114677564 0010026 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\WebPage;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* FAQPage graph class.
*
* @since 4.0.0
*/
class FAQPage extends WebPage {
/**
* The graph type.
*
* @since 4.0.0
*
* @var string
*/
protected $type = 'FAQPage';
} WebPage/MedicalWebPage.php 0000666 00000000650 15114677564 0011405 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\WebPage;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* MedicalWebPage graph class.
*
* @since 4.6.4
*/
class MedicalWebPage extends WebPage {
/**
* The graph type.
*
* This value can be overridden by WebPage child graphs that are more specific.
*
* @since 4.6.4
*
* @var string
*/
protected $type = 'MedicalWebPage';
} WebPage/AboutPage.php 0000666 00000000504 15114677564 0010461 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\WebPage;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* AboutPage graph class.
*
* @since 4.0.0
*/
class AboutPage extends WebPage {
/**
* The graph type.
*
* @since 4.0.0
*
* @var string
*/
protected $type = 'AboutPage';
} WebPage/CollectionPage.php 0000666 00000000523 15114677564 0011503 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\WebPage;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* CollectionPage graph class.
*
* @since 4.0.0
*/
class CollectionPage extends WebPage {
/**
* The graph type.
*
* @since 4.0.0
*
* @var string
*/
protected $type = 'CollectionPage';
} WebPage/WebPage.php 0000666 00000005577 15114677564 0010143 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\WebPage;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Schema\Graphs;
/**
* WebPage graph class.
*
* @since 4.0.0
*/
class WebPage extends Graphs\Graph {
/**
* The graph type.
*
* This value can be overridden by WebPage child graphs that are more specific.
*
* @since 4.0.0
*
* @var string
*/
protected $type = 'WebPage';
/**
* Returns the graph data.
*
* @since 4.0.0
*
* @return array $data The graph data.
*/
public function get() {
$homeUrl = trailingslashit( home_url() );
$data = [
'@type' => $this->type,
'@id' => aioseo()->schema->context['url'] . '#' . strtolower( $this->type ),
'url' => aioseo()->schema->context['url'],
'name' => aioseo()->meta->title->getTitle(),
'description' => aioseo()->schema->context['description'],
'inLanguage' => aioseo()->helpers->currentLanguageCodeBCP47(),
'isPartOf' => [ '@id' => $homeUrl . '#website' ]
];
$breadcrumbs = aioseo()->breadcrumbs->frontend->getBreadcrumbs() ?? '';
if ( ! empty( $breadcrumbs ) ) {
$data['breadcrumb'] = [ '@id' => aioseo()->schema->context['url'] . '#breadcrumblist' ];
}
if ( is_singular() && 'page' !== get_post_type() ) {
$post = aioseo()->helpers->getPost();
if ( is_a( $post, 'WP_Post' ) && post_type_supports( $post->post_type, 'author' ) ) {
$author = get_author_posts_url( $post->post_author );
if ( ! empty( $author ) ) {
if ( ! in_array( 'PersonAuthor', aioseo()->schema->graphs, true ) ) {
aioseo()->schema->graphs[] = 'PersonAuthor';
}
$data['author'] = [ '@id' => $author . '#author' ];
$data['creator'] = [ '@id' => $author . '#author' ];
}
}
}
if ( isset( aioseo()->schema->context['description'] ) && aioseo()->schema->context['description'] ) {
$data['description'] = aioseo()->schema->context['description'];
}
if ( is_singular() ) {
if ( ! isset( aioseo()->schema->context['object'] ) || ! aioseo()->schema->context['object'] ) {
return $this->getAddonData( $data, 'webPage' );
}
$post = aioseo()->schema->context['object'];
if ( has_post_thumbnail( $post ) ) {
$image = $this->image( get_post_thumbnail_id(), 'mainImage' );
if ( $image ) {
$data['image'] = $image;
$data['primaryImageOfPage'] = [
'@id' => aioseo()->schema->context['url'] . '#mainImage'
];
}
}
$data['datePublished'] = mysql2date( DATE_W3C, $post->post_date, false );
$data['dateModified'] = mysql2date( DATE_W3C, $post->post_modified, false );
return $this->getAddonData( $data, 'webPage' );
}
if ( is_front_page() ) {
$data['about'] = [ '@id' => trailingslashit( home_url() ) . '#' . aioseo()->options->searchAppearance->global->schema->siteRepresents ];
}
return $this->getAddonData( $data, 'webPage' );
}
} WebPage/CheckoutPage.php 0000666 00000000642 15114677564 0011157 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\WebPage;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* CheckoutPage graph class.
*
* @since 4.6.4
*/
class CheckoutPage extends WebPage {
/**
* The graph type.
*
* This value can be overridden by WebPage child graphs that are more specific.
*
* @since 4.6.4
*
* @var string
*/
protected $type = 'CheckoutPage';
} WebPage/SearchResultsPage.php 0000666 00000000534 15114677564 0012201 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\WebPage;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* SearchResultsPage graph class.
*
* @since 4.0.0
*/
class SearchResultsPage extends WebPage {
/**
* The graph type.
*
* @since 4.0.0
*
* @var string
*/
protected $type = 'SearchResultsPage';
} WebPage/ContactPage.php 0000666 00000000512 15114677564 0011001 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\WebPage;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* ContactPage graph class.
*
* @since 4.0.0
*/
class ContactPage extends WebPage {
/**
* The graph type.
*
* @since 4.0.0
*
* @var string
*/
protected $type = 'ContactPage';
} WebPage/ProfilePage.php 0000666 00000004274 15114677564 0011017 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\WebPage;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Integrations\BuddyPress as BuddyPressIntegration;
/**
* ProfilePage graph class.
*
* @since 4.0.0
*/
class ProfilePage extends WebPage {
/**
* The graph type.
*
* @since 4.5.6
*
* @var string
*/
protected $type = 'ProfilePage';
/**
* Returns the graph data.
*
* @since 4.5.4
*
* @return array The graph data.
*/
public function get() {
$data = parent::get();
$post = aioseo()->helpers->getPost();
$author = get_queried_object();
if (
! is_a( $author, 'WP_User' ) &&
( is_singular() && ! is_a( $post, 'WP_Post' ) )
) {
return [];
}
global $wp_query; // phpcs:ignore Squiz.NamingConventions.ValidVariableName
$articles = [];
$authorId = $author->ID ?? $post->post_author ?? 0;
foreach ( $wp_query->posts as $post ) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName
if ( $post->post_author !== $authorId ) {
continue;
}
$articles[] = [
'@type' => 'Article',
'url' => get_permalink( $post->ID ),
'headline' => $post->post_title,
'datePublished' => mysql2date( DATE_W3C, $post->post_date, false ),
'dateModified' => mysql2date( DATE_W3C, $post->post_modified, false ),
'author' => [
'@id' => get_author_posts_url( $authorId ) . '#author'
]
];
}
$data = array_merge( $data, [
'dateCreated' => mysql2date( DATE_W3C, $author->user_registered, false ),
'mainEntity' => [
'@id' => get_author_posts_url( $authorId ) . '#author'
],
'hasPart' => $articles
] );
if (
BuddyPressIntegration::isComponentPage() &&
'bp-member_single' === aioseo()->standalone->buddyPress->component->templateType
) {
if ( ! isset( $data['mainEntity'] ) ) {
$data['mainEntity'] = [];
}
$data['mainEntity']['@type'] = 'Person';
$data['mainEntity']['name'] = aioseo()->standalone->buddyPress->component->author->display_name;
$data['mainEntity']['url'] = BuddyPressIntegration::getComponentSingleUrl( 'member', aioseo()->standalone->buddyPress->component->author->ID );
}
return $data;
}
} WebPage/ItemPage.php 0000666 00000000626 15114677564 0010312 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\WebPage;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* ItemPage graph class.
*
* @since 4.0.0
*/
class ItemPage extends WebPage {
/**
* The graph type.
*
* This value can be overridden by WebPage child graphs that are more specific.
*
* @since 4.0.0
*
* @var string
*/
protected $type = 'ItemPage';
} WebPage/PersonAuthor.php 0000666 00000004016 15114677564 0011245 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\WebPage;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Schema\Graphs;
/**
* Person Author graph class.
* This a secondary Person graph for post authors and BuddyPress profile pages.
*
* @since 4.0.0
*/
class PersonAuthor extends Graphs\Graph {
/**
* Returns the graph data.
*
* @since 4.0.0
*
* @param int $userId The user ID.
* @return array $data The graph data.
*/
public function get( $userId = null ) {
$post = aioseo()->helpers->getPost();
$user = get_queried_object();
$isAuthorPage = is_author() && is_a( $user, 'WP_User' );
if (
(
( ! is_singular() && ! $isAuthorPage ) ||
( is_singular() && ! is_a( $post, 'WP_Post' ) )
) &&
! $userId
) {
return [];
}
// Dynamically determine the User ID.
if ( ! $userId ) {
$userId = $isAuthorPage ? $user->ID : $post->post_author;
if ( function_exists( 'bp_is_user' ) && bp_is_user() ) {
$userId = intval( wp_get_current_user()->ID );
}
}
if ( ! $userId ) {
return [];
}
$authorUrl = get_author_posts_url( $userId );
$data = [
'@type' => 'Person',
'@id' => $authorUrl . '#author',
'url' => $authorUrl,
'name' => get_the_author_meta( 'display_name', $userId )
];
$avatar = $this->avatar( $userId, 'authorImage' );
if ( $avatar ) {
$data['image'] = $avatar;
}
$socialUrls = array_values( $this->getUserProfiles( $userId ) );
if ( $socialUrls ) {
$data['sameAs'] = $socialUrls;
}
if ( is_author() ) {
$data['mainEntityOfPage'] = [
'@id' => aioseo()->schema->context['url'] . '#profilepage'
];
}
// Check if our addons need to modify this graph.
$addonsPersonAuthorData = array_filter( aioseo()->addons->doAddonFunction( 'personAuthor', 'get', [
'userId' => $userId,
'data' => $data
] ) );
foreach ( $addonsPersonAuthorData as $addonPersonAuthorData ) {
$data = array_merge( $data, $addonPersonAuthorData );
}
return $data;
}
} Traits/Image.php 0000666 00000005462 15114677564 0007600 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\Traits;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Trait that handles images for the graphs.
*
* @since 4.2.5
*/
trait Image {
/**
* Builds the graph data for a given image with a given schema ID.
*
* @since 4.0.0
*
* @param int $imageId The image ID.
* @param string $graphId The graph ID (optional).
* @return array $data The image graph data.
*/
protected function image( $imageId, $graphId = '' ) {
$attachmentId = is_string( $imageId ) && ! is_numeric( $imageId ) ? aioseo()->helpers->attachmentUrlToPostId( $imageId ) : $imageId;
$imageUrl = wp_get_attachment_image_url( $attachmentId, 'full' );
$data = [
'@type' => 'ImageObject',
'url' => $imageUrl ? $imageUrl : $imageId,
];
if ( $graphId ) {
$baseUrl = aioseo()->schema->context['url'] ?? aioseo()->helpers->getUrl();
$data['@id'] = trailingslashit( $baseUrl ) . '#' . $graphId;
}
if ( ! $attachmentId ) {
return $data;
}
$metaData = wp_get_attachment_metadata( $attachmentId );
if ( $metaData && ! empty( $metaData['width'] ) && ! empty( $metaData['height'] ) ) {
$data['width'] = (int) $metaData['width'];
$data['height'] = (int) $metaData['height'];
}
$caption = $this->getImageCaption( $attachmentId );
if ( ! empty( $caption ) ) {
$data['caption'] = $caption;
}
return $data;
}
/**
* Get the image caption.
*
* @since 4.1.4
*
* @param int $attachmentId The attachment ID.
* @return string The caption.
*/
private function getImageCaption( $attachmentId ) {
$caption = wp_get_attachment_caption( $attachmentId );
if ( ! empty( $caption ) ) {
return $caption;
}
return get_post_meta( $attachmentId, '_wp_attachment_image_alt', true );
}
/**
* Returns the graph data for the avatar of a given user.
*
* @since 4.0.0
*
* @param int $userId The user ID.
* @param string $graphId The graph ID.
* @return array The graph data.
*/
protected function avatar( $userId, $graphId ) {
if ( ! get_option( 'show_avatars' ) ) {
return [];
}
$avatar = get_avatar_data( $userId );
if ( ! $avatar['found_avatar'] ) {
return [];
}
return array_filter( [
'@type' => 'ImageObject',
'@id' => aioseo()->schema->context['url'] . "#$graphId",
'url' => $avatar['url'],
'width' => $avatar['width'],
'height' => $avatar['height'],
'caption' => get_the_author_meta( 'display_name', $userId )
] );
}
/**
* Returns the graph data for the post's featured image.
*
* @since 4.2.5
*
* @return string The featured image URL.
*/
protected function getFeaturedImage() {
$post = aioseo()->helpers->getPost();
return has_post_thumbnail( $post ) ? $this->image( get_post_thumbnail_id() ) : '';
}
} KnowledgeGraph/KgOrganization.php 0000666 00000005336 15114677564 0013137 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\KnowledgeGraph;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use \AIOSEO\Plugin\Common\Schema\Graphs;
/**
* Knowledge Graph Organization graph class.
*
* @since 4.0.0
*/
class KgOrganization extends Graphs\Graph {
/**
* Returns the graph data.
*
* @since 4.0.0
*
* @return array $data The graph data.
*/
public function get() {
$homeUrl = trailingslashit( home_url() );
$organizationName = aioseo()->tags->replaceTags( aioseo()->options->searchAppearance->global->schema->organizationName );
$organizationDescription = aioseo()->tags->replaceTags( aioseo()->options->searchAppearance->global->schema->organizationDescription );
$data = [
'@type' => 'Organization',
'@id' => $homeUrl . '#organization',
'name' => $organizationName ? $organizationName : aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'name' ) ),
'description' => $organizationDescription,
'url' => $homeUrl,
'email' => aioseo()->options->searchAppearance->global->schema->email,
'telephone' => aioseo()->options->searchAppearance->global->schema->phone,
'foundingDate' => aioseo()->options->searchAppearance->global->schema->foundingDate
];
$numberOfEmployeesData = aioseo()->options->searchAppearance->global->schema->numberOfEmployees->all();
if (
$numberOfEmployeesData['isRange'] &&
isset( $numberOfEmployeesData['from'] ) &&
isset( $numberOfEmployeesData['to'] ) &&
0 < $numberOfEmployeesData['to']
) {
$data['numberOfEmployees'] = [
'@type' => 'QuantitativeValue',
'minValue' => $numberOfEmployeesData['from'],
'maxValue' => $numberOfEmployeesData['to']
];
}
if (
! $numberOfEmployeesData['isRange'] &&
! empty( $numberOfEmployeesData['number'] )
) {
$data['numberOfEmployees'] = [
'@type' => 'QuantitativeValue',
'value' => $numberOfEmployeesData['number']
];
}
$logo = $this->logo();
if ( ! empty( $logo ) ) {
$data['logo'] = $logo;
$data['image'] = [ '@id' => $data['logo']['@id'] ];
}
$socialUrls = array_values( $this->getOrganizationProfiles() );
if ( $socialUrls ) {
$data['sameAs'] = $socialUrls;
}
$data = $this->getAddonData( $data, 'kgOrganization' );
return $data;
}
/**
* Returns the logo data.
*
* @since 4.0.0
*
* @return array The logo data.
*/
public function logo() {
$logo = aioseo()->options->searchAppearance->global->schema->organizationLogo;
if ( $logo ) {
return $this->image( $logo, 'organizationLogo' );
}
$imageId = aioseo()->helpers->getSiteLogoId();
if ( $imageId ) {
return $this->image( $imageId, 'organizationLogo' );
}
return [];
}
} KnowledgeGraph/KgPerson.php 0000666 00000003457 15114677564 0011743 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\KnowledgeGraph;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use \AIOSEO\Plugin\Common\Schema\Graphs;
/**
* Knowledge Graph Person graph class.
* This is the main Person graph that can be set to represent the site.
*
* @since 4.0.0
*/
class KgPerson extends Graphs\Graph {
/**
* Returns the graph data.
*
* @since 4.0.0
*
* @return array $data The graph data.
*/
public function get() {
if ( 'person' !== aioseo()->options->searchAppearance->global->schema->siteRepresents ) {
return [];
}
$person = aioseo()->options->searchAppearance->global->schema->person;
if ( 'manual' === $person ) {
return $this->manual();
}
$person = intval( $person );
if ( empty( $person ) ) {
return [];
}
$data = [
'@type' => 'Person',
'@id' => trailingslashit( home_url() ) . '#person',
'name' => get_the_author_meta( 'display_name', $person )
];
$avatar = $this->avatar( $person, 'personImage' );
if ( $avatar ) {
$data['image'] = $avatar;
}
$socialUrls = array_values( $this->getUserProfiles( $person ) );
if ( $socialUrls ) {
$data['sameAs'] = $socialUrls;
}
return $data;
}
/**
* Returns the data for the person if it is set manually.
*
* @since 4.0.0
*
* @return array $data The graph data.
*/
private function manual() {
$data = [
'@type' => 'Person',
'@id' => trailingslashit( home_url() ) . '#person',
'name' => aioseo()->options->searchAppearance->global->schema->personName
];
$logo = aioseo()->options->searchAppearance->global->schema->personLogo;
if ( $logo ) {
$data['image'] = $logo;
}
$socialUrls = array_values( $this->getOrganizationProfiles() );
if ( $socialUrls ) {
$data['sameAs'] = $socialUrls;
}
return $data;
}
} WebSite.php 0000666 00000001747 15114677564 0006654 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WebSite graph class.
*
* @since 4.0.0
*/
class WebSite extends Graph {
/**
* Returns the graph data.
*
* @since 4.0.0
*
* @return array $data The graph data.
*/
public function get() {
$homeUrl = trailingslashit( home_url() );
$data = [
'@type' => 'WebSite',
'@id' => $homeUrl . '#website',
'url' => $homeUrl,
'name' => aioseo()->helpers->getWebsiteName(),
'alternateName' => aioseo()->tags->replaceTags( aioseo()->options->searchAppearance->global->schema->websiteAlternateName ),
'description' => aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'description' ) ),
'inLanguage' => aioseo()->helpers->currentLanguageCodeBCP47(),
'publisher' => [ '@id' => $homeUrl . '#' . aioseo()->options->searchAppearance->global->schema->siteRepresents ]
];
return $data;
}
} BreadcrumbList.php 0000666 00000004205 15114677564 0010204 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* BreadcrumbList graph class.
*
* @since 4.0.0
*/
class BreadcrumbList extends Graph {
/**
* Returns the graph data.
*
* @since 4.0.0
*
* @return array The graph data.
*/
public function get() {
$breadcrumbs = aioseo()->breadcrumbs->frontend->getBreadcrumbs() ?? '';
if ( ! $breadcrumbs ) {
return [];
}
// Set the position for each breadcrumb.
foreach ( $breadcrumbs as $k => $breadcrumb ) {
if ( ! isset( $breadcrumb['position'] ) ) {
$breadcrumbs[ $k ]['position'] = $k + 1;
}
}
$trailLength = count( $breadcrumbs );
if ( ! $trailLength ) {
return [];
}
$listItems = [];
foreach ( $breadcrumbs as $breadcrumb ) {
if ( empty( $breadcrumb['link'] ) ) {
continue;
}
$listItem = [
'@type' => 'ListItem',
'@id' => $breadcrumb['link'] . '#listItem',
'position' => $breadcrumb['position'],
'name' => $breadcrumb['label'] ?? ''
];
// Don't add "item" prop for last crumb.
if ( $trailLength !== $breadcrumb['position'] ) {
$listItem['item'] = $breadcrumb['link'];
}
if ( 1 === $trailLength ) {
$listItems[] = $listItem;
continue;
}
if ( $trailLength > $breadcrumb['position'] && ! empty( $breadcrumbs[ $breadcrumb['position'] ]['label'] ) ) {
$listItem['nextItem'] = [
'@type' => 'ListItem',
'@id' => $breadcrumbs[ $breadcrumb['position'] ]['link'] . '#listItem',
'name' => $breadcrumbs[ $breadcrumb['position'] ]['label'],
];
}
if ( 1 < $breadcrumb['position'] && ! empty( $breadcrumbs[ $breadcrumb['position'] - 2 ]['label'] ) ) {
$listItem['previousItem'] = [
'@type' => 'ListItem',
'@id' => $breadcrumbs[ $breadcrumb['position'] - 2 ]['link'] . '#listItem',
'name' => $breadcrumbs[ $breadcrumb['position'] - 2 ]['label'],
];
}
$listItems[] = $listItem;
}
$data = [
'@type' => 'BreadcrumbList',
'@id' => aioseo()->schema->context['url'] . '#breadcrumblist',
'itemListElement' => $listItems
];
return $data;
}
} Graph.php 0000666 00000004542 15114677564 0006347 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Traits as CommonTraits;
/**
* The base graph class.
*
* @since 4.0.0
*/
abstract class Graph {
use Traits\Image;
use CommonTraits\SocialProfiles;
/**
* The graph data to overwrite.
*
* @since 4.7.6
*
* @var array
*/
protected static $overwriteGraphData = [];
/**
* Returns the graph data.
*
* @since 4.0.0
*/
abstract public function get();
/**
* Iterates over a list of functions and sets the results as graph data.
*
* @since 4.0.13
*
* @param array $data The graph data to add to.
* @param array $dataFunctions List of functions to loop over, associated with a graph property.
* @return array $data The graph data with the results added.
*/
protected function getData( $data, $dataFunctions ) {
foreach ( $dataFunctions as $k => $f ) {
if ( ! method_exists( $this, $f ) ) {
continue;
}
$value = $this->$f();
if ( $value || in_array( $k, aioseo()->schema->nullableFields, true ) ) {
$data[ $k ] = $value;
}
}
return $data;
}
/**
* Decodes a multiselect field and returns the values.
*
* @since 4.6.4
*
* @param string $json The JSON encoded multiselect field.
* @return array The decoded values.
*/
protected function extractMultiselectTags( $json ) {
$tags = is_string( $json ) ? json_decode( $json ) : [];
if ( ! $tags ) {
return [];
}
return wp_list_pluck( $tags, 'value' );
}
/**
* Merges in data from our addon plugins.
*
* @since 4.5.6
* @version 4.6.4 Moved to main graph class.
*
* @param array $data The graph data.
* @return array The graph data.
*/
protected function getAddonData( $data, $className, $methodName = 'getAdditionalGraphData' ) {
$addonData = array_filter( aioseo()->addons->doAddonFunction( $className, $methodName, [
'postId' => get_the_ID(),
'data' => $data
] ) );
foreach ( $addonData as $addonGraphData ) {
$data = array_merge( $data, $addonGraphData );
}
return $data;
}
/**
* A way to overwrite the graph data.
*
* @since 4.7.6
*
* @param array $data The data to overwrite.
* @return void
*/
public static function setOverwriteGraphData( $data ) {
self::$overwriteGraphData[ static::class ] = $data;
}
} Article/NewsArticle.php 0000666 00000002315 15114677564 0011105 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\Article;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* News Article graph class.
*
* @since 4.0.0
*/
class NewsArticle extends Article {
/**
* Returns the graph data.
*
* @since 4.0.0
*
* @param object $graphData The graph data.
* @return array The parsed graph data.
*/
public function get( $graphData = null ) {
if ( ! empty( self::$overwriteGraphData[ __CLASS__ ] ) ) {
$graphData = json_decode( wp_json_encode( wp_parse_args( self::$overwriteGraphData[ __CLASS__ ], $graphData ) ) );
}
$data = parent::get( $graphData );
if ( ! $data ) {
return [];
}
$data['@type'] = 'NewsArticle';
$data['@id'] = ! empty( $graphData->id ) ? aioseo()->schema->context['url'] . $graphData->id : aioseo()->schema->context['url'] . '#newsarticle';
$date = ! empty( $graphData->properties->datePublished )
? mysql2date( 'F j, Y', $graphData->properties->datePublished, false )
: get_the_date( 'F j, Y' );
if ( $date ) {
// Translators: 1 - A date (e.g. September 2, 2022).
$data['dateline'] = sprintf( __( 'Published on %1$s.', 'all-in-one-seo-pack' ), $date );
}
return $data;
}
} Article/BlogPosting.php 0000666 00000001307 15114677564 0011114 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\Article;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Blog Posting graph class.
*
* @since 4.0.0
*/
class BlogPosting extends Article {
/**
* Returns the graph data.
*
* @since 4.0.0
*
* @return object $graphData The graph data.
* @return array The parsed graph data.
*/
public function get( $graphData = null ) {
$data = parent::get( $graphData );
if ( ! $data ) {
return [];
}
$data['@type'] = 'BlogPosting';
$data['@id'] = ! empty( $graphData->id ) ? aioseo()->schema->context['url'] . $graphData->id : aioseo()->schema->context['url'] . '#blogposting';
return $data;
}
} Article/Article.php 0000666 00000011770 15114677564 0010255 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs\Article;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Schema\Graphs;
/**
* Article graph class.
*
* @since 4.0.0
*/
class Article extends Graphs\Graph {
/**
* Returns the graph data.
*
* @since 4.2.5
*
* @param Object $graphData The graph data.
* @return array The parsed graph data.
*/
public function get( $graphData = null ) {
$post = aioseo()->helpers->getPost();
if ( ! is_a( $post, 'WP_Post' ) ) {
return [];
}
$data = [
'@type' => 'Article',
'@id' => ! empty( $graphData->id ) ? aioseo()->schema->context['url'] . $graphData->id : aioseo()->schema->context['url'] . '#article',
'name' => ! empty( $graphData->properties->name ) ? $graphData->properties->name : aioseo()->schema->context['name'],
'headline' => ! empty( $graphData->properties->headline ) ? $graphData->properties->headline : get_the_title(),
'description' => ! empty( $graphData->properties->description ) ? $graphData->properties->description : '',
'author' => [
'@type' => 'Person',
'name' => ! empty( $graphData->properties->author->name ) ? $graphData->properties->author->name : get_the_author_meta( 'display_name' ),
'url' => ! empty( $graphData->properties->author->url ) ? $graphData->properties->author->url : '',
],
'publisher' => [ '@id' => trailingslashit( home_url() ) . '#' . aioseo()->options->searchAppearance->global->schema->siteRepresents ],
'image' => ! empty( $graphData->properties->image ) ? $this->image( $graphData->properties->image ) : $this->postImage( $post ),
'datePublished' => ! empty( $graphData->properties->dates->datePublished )
? mysql2date( DATE_W3C, $graphData->properties->dates->datePublished, false )
: mysql2date( DATE_W3C, $post->post_date, false ),
'dateModified' => ! empty( $graphData->properties->dates->dateModified )
? mysql2date( DATE_W3C, $graphData->properties->dates->dateModified, false )
: mysql2date( DATE_W3C, $post->post_modified, false ),
'inLanguage' => aioseo()->helpers->currentLanguageCodeBCP47(),
'commentCount' => get_comment_count( $post->ID )['approved'],
'mainEntityOfPage' => empty( $graphData ) ? [ '@id' => aioseo()->schema->context['url'] . '#webpage' ] : '',
'isPartOf' => empty( $graphData ) ? [ '@id' => aioseo()->schema->context['url'] . '#webpage' ] : ''
];
if ( empty( $graphData->properties->author->name ) ) {
if ( ! in_array( 'PersonAuthor', aioseo()->schema->graphs, true ) ) {
aioseo()->schema->graphs[] = 'PersonAuthor';
}
$data['author'] = [
'@id' => get_author_posts_url( $post->post_author ) . '#author'
];
}
if ( ! empty( $graphData->properties->keywords ) ) {
$keywords = json_decode( $graphData->properties->keywords, true );
$keywords = array_map( function ( $keywordObject ) {
return $keywordObject['value'];
}, $keywords );
$data['keywords'] = implode( ', ', $keywords );
}
if ( isset( $graphData->properties->dates->include ) && ! $graphData->properties->dates->include ) {
unset( $data['datePublished'] );
unset( $data['dateModified'] );
}
$postTaxonomies = get_post_taxonomies( $post );
$postTerms = [];
foreach ( $postTaxonomies as $taxonomy ) {
$terms = get_the_terms( $post, $taxonomy );
if ( $terms ) {
$postTerms = array_merge( $postTerms, wp_list_pluck( $terms, 'name' ) );
}
}
if ( ! empty( $postTerms ) ) {
$data['articleSection'] = implode( ', ', $postTerms );
}
$pageNumber = aioseo()->helpers->getPageNumber();
if ( 1 < $pageNumber ) {
$data['pagination'] = $pageNumber;
}
return $data;
}
/**
* Returns the graph data for the post image.
*
* @since 4.0.0
*
* @param \WP_Post $post The post object.
* @return array The image graph data.
*/
private function postImage( $post ) {
$featuredImage = $this->getFeaturedImage();
if ( $featuredImage ) {
return $featuredImage;
}
preg_match_all( '#<img[^>]+src="([^">]+)"#', (string) $post->post_content, $matches );
if ( isset( $matches[1] ) && isset( $matches[1][0] ) ) {
$url = aioseo()->helpers->removeImageDimensions( $matches[1][0] );
$imageId = aioseo()->helpers->attachmentUrlToPostId( $url );
if ( $imageId ) {
return $this->image( $imageId, 'articleImage' );
} else {
return $this->image( $url, 'articleImage' );
}
}
if ( 'organization' === aioseo()->options->searchAppearance->global->schema->siteRepresents ) {
$logo = ( new Graphs\KnowledgeGraph\KgOrganization() )->logo();
if ( ! empty( $logo ) ) {
$logo['@id'] = trailingslashit( home_url() ) . '#articleImage';
return $logo;
}
} else {
$avatar = $this->avatar( $post->post_author, 'articleImage' );
if ( $avatar ) {
return $avatar;
}
}
$imageId = aioseo()->helpers->getSiteLogoId();
if ( $imageId ) {
return $this->image( $imageId, 'articleImage' );
}
return [];
}
} AmpStory.php 0000666 00000002471 15114677564 0007063 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Schema\Graphs;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* AmpStory graph class.
*
* @since 4.7.6
*/
class AmpStory extends Graph {
/**
* Returns the graph data.
*
* @since 4.7.6
*
* @return array The parsed graph data.
*/
public function get() {
$post = aioseo()->helpers->getPost();
if ( ! is_a( $post, 'WP_Post' ) || 'web-story' !== $post->post_type ) {
return [];
}
$data = [
'@type' => 'AmpStory',
'@id' => aioseo()->schema->context['url'] . '#amp-story',
'name' => aioseo()->schema->context['name'],
'headline' => get_the_title(),
'author' => [
'@id' => get_author_posts_url( $post->post_author ) . '#author'
],
'publisher' => [ '@id' => trailingslashit( home_url() ) . '#' . aioseo()->options->searchAppearance->global->schema->siteRepresents ],
'image' => $this->getFeaturedImage(),
'datePublished' => mysql2date( DATE_W3C, $post->post_date, false ),
'dateModified' => mysql2date( DATE_W3C, $post->post_modified, false ),
'inLanguage' => aioseo()->helpers->currentLanguageCodeBCP47()
];
if ( ! in_array( 'PersonAuthor', aioseo()->schema->graphs, true ) ) {
aioseo()->schema->graphs[] = 'PersonAuthor';
}
return $data;
}
}