| Server IP : 89.39.208.18 / Your IP : 216.73.217.74 Web Server : LiteSpeed System : User : ( ) PHP Version : 7.4.33 Disable Function : eval,./,ln,passthru,dl,system,exec,popen,shell_exec,posix_getpwuid,posix_uname,ftp_exec,posix_uname,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,get_current_user,getmyuid,getmygid,listen,chgrp,apache_note,apache_setenv,apache_child_terminate,closelog,debugger_off,debugge_on,ini_restore,netscript,escapeshellarg,cmd,backtick,virtual,show_sourc,show_source,pclose,pcntl_exec,datasec,old_offset,ctrl_dir,ini_alter,leak,listen,chgrp,apache_setenv,define_syslog_variables,root,diskfreespace,disk_free_space,disk_total_space,posix_kill,getmyuid,getmygid,apache_child_terminate,php_ini_scanned_files,ls,ps_aux,chown,getrusage,posixc,posame,chgrp,posix_setuid,posix_setsid,posix_setgid,apache_note,apache_setenv,x_getuid,e_ini_file,nfo,SQL,mysql_li,t_dbs,filegroup,highlight_file,ilegetcontents,get_dir,popen,popens,pfsockopen,dos_conv,apache_get_modules,crack_check,crack_closedict,rar_open,bzopen,bzread,bzwrite,shellcode,posix_isatty,posix_getservbyname,escapeshellarg,hypot,pg_host,pos,posix_access,inurl,posix_times,posix_mknod,pclose,ps_fill,symlink,id,escapeshellcmd,php_uname,phpinfo MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home3/mahyarcake/www/wp-content/plugins/wordpress-seo-premium/src/integrations/third-party/ |
Upload File : |
<?php
namespace Yoast\WP\SEO\Premium\Integrations\Third_Party;
use WPSEO_Schema_Context;
use Yoast\WP\SEO\Conditionals\Front_End_Conditional;
use Yoast\WP\SEO\Integrations\Integration_Interface;
use Yoast\WP\SEO\Premium\Conditionals\EDD_Conditional;
use Yoast\WP\SEO\Surfaces\Meta_Surface;
/**
* EDD integration.
*/
class EDD implements Integration_Interface {
/**
* The meta surface.
*
* @var Meta_Surface
*/
private $meta;
/**
* Returns the conditionals based on which this loadable should be active.
*
* @return array
*/
public static function get_conditionals() {
return [ Front_End_Conditional::class, EDD_Conditional::class ];
}
/**
* EDD constructor.
*
* @codeCoverageIgnore It only sets dependencies.
*
* @param Meta_Surface $meta The meta surface.
*/
public function __construct( Meta_Surface $meta ) {
$this->meta = $meta;
}
/**
* Initializes the integration.
*
* This is the place to register hooks and filters.
*
* @return void
*/
public function register_hooks() {
\add_filter( 'edd_generate_download_structured_data', [ $this, 'filter_download_schema' ] );
\add_filter( 'wpseo_schema_organization', [ $this, 'filter_organization_schema' ] );
\add_filter( 'wpseo_schema_webpage', [ $this, 'filter_webpage_schema' ], 10, 2 );
}
/**
* Make sure the Organization is classified as a Brand too.
*
* @param array $data The organization schema.
*
* @return array
*/
public function filter_organization_schema( $data ) {
if ( \is_singular( 'download' ) ) {
$data['@type'] = [ 'Organization', 'Brand' ];
}
return $data;
}
/**
* Make sure the WebPage schema contains reference to the product.
*
* @param array $data The schema Webpage data.
* @param WPSEO_Schema_Context $context Context object.
*
* @return array
*/
public function filter_webpage_schema( $data, $context ) {
if ( \is_singular( [ 'download' ] ) ) {
$data['about'] = [ '@id' => $context->canonical . '#/schema/edd-product/' . \get_the_ID() ];
$data['mainEntity'] = [ '@id' => $context->canonical . '#/schema/edd-product/' . \get_the_ID() ];
}
return $data;
}
/**
* Filter the structured data output for a download to tie into Yoast SEO's output.
*
* @param array $data Structured data for a download.
*
* @return array
*/
public function filter_download_schema( $data ) {
$data['@id'] = $this->meta->for_current_page()->canonical . '#/schema/edd-product/' . \get_the_ID();
$data['sku'] = (string) $data['sku'];
$data['brand'] = $this->return_organization_node();
$data['offers'] = $this->clean_up_offer( $data['offers'] );
if ( ! isset( $data['description'] ) ) {
$data['description'] = $this->meta->for_current_page()->open_graph_description;
}
return $data;
}
/**
* Cleans up EDD generated Offers.
*
* @param array $offer The schema array.
*
* @return array
*/
private function clean_up_offer( $offer ) {
// Checking for not isset @type makes sure there are multiple offers in the offer list. It is always an array.
if ( ! isset( $offer['@type'] ) ) {
foreach ( $offer as $key => $o ) {
if ( \array_key_exists( 'priceValidUntil', $o ) && $o['priceValidUntil'] === null ) {
unset( $offer[ $key ]['priceValidUntil'] );
}
$offer[ $key ]['seller'] = $this->return_organization_node();
}
}
else {
if ( \array_key_exists( 'priceValidUntil', $offer ) && $offer['priceValidUntil'] === null ) {
unset( $offer['priceValidUntil'] );
}
$offer['seller'] = $this->return_organization_node();
}
return $offer;
}
/**
* Returns a Schema node for the current site's Organization.
*
* @return string[]
*/
private function return_organization_node() {
return [
'@type' => [ 'Organization', 'Brand' ],
'@id' => $this->meta->for_home_page()->canonical . '#organization',
];
}
}