eId then 0 else 1 end, $orderBy";
}
}
// Include the blog page in the posts post type unless manually excluded.
if (
$blogPageId &&
! in_array( $blogPageId, $excludedPostIds, true ) &&
in_array( 'post', $postTypesArray, true )
) {
// We are using a database class hack to get in an OR clause to
// bypass all the other WHERE statements and just include the
// blog page ID manually.
$query->whereRaw( "1=1 OR `p`.`ID` = $blogPageId" );
// Custom order by statement to always move the blog posts page to the top.
$orderBy = "case when `p`.`ID` = $blogPageId then 0 else 1 end, $orderBy";
}
}
if ( $excludedPosts ) {
$query->whereRaw( "( `p`.`ID` NOT IN ( $excludedPosts ) OR post_id = $homePageId )" );
}
// Exclude posts assigned to excluded terms.
$excludedTerms = aioseo()->sitemap->helpers->excludedTerms();
if ( $excludedTerms ) {
$termRelationshipsTable = aioseo()->core->db->db->prefix . 'term_relationships';
$query->whereRaw("
( `p`.`ID` NOT IN
(
SELECT `tr`.`object_id`
FROM `$termRelationshipsTable` as tr
WHERE `tr`.`term_taxonomy_id` IN ( $excludedTerms )
)
)" );
}
if ( $maxAge ) {
$query->whereRaw( "( `p`.`post_date_gmt` >= '$maxAge' )" );
}
if (
'rss' === aioseo()->sitemap->type ||
(
aioseo()->sitemap->indexes &&
empty( $additionalArgs['root'] ) &&
( empty( $additionalArgs['count'] ) || ! $additionalArgs['count'] )
)
) {
$query->limit( aioseo()->sitemap->linksPerIndex, aioseo()->sitemap->offset );
}
$query->orderBy( $orderBy );
$query = $this->filterPostQuery( $query, $postTypes );
// Return the total if we are just counting the posts.
if ( ! empty( $additionalArgs['count'] ) && $additionalArgs['count'] ) {
return (int) $query->run( true, 'var' )
->result();
}
$posts = $query->run()
->result();
// Convert ID from string to int.
foreach ( $posts as $post ) {
$post->ID = (int) $post->ID;
}
return $this->filterPosts( $posts );
}
/**
* Filters the post query.
*
* @since 4.1.4
*
* @param \AIOSEO\Plugin\Common\Utils\Database $query The query.
* @param string $postType The post type.
* @return \AIOSEO\Plugin\Common\Utils\Database The filtered query.
*/
private function filterPostQuery( $query, $postType ) {
switch ( $postType ) {
case 'product':
return $this->excludeHiddenProducts( $query );
default:
break;
}
return $query;
}
/**
* Adds a condition to the query to exclude hidden WooCommerce products.
*
* @since 4.1.4
*
* @param \AIOSEO\Plugin\Common\Utils\Database $query The query.
* @return \AIOSEO\Plugin\Common\Utils\Database The filtered query.
*/
private function excludeHiddenProducts( $query ) {
if (
! aioseo()->helpers->isWooCommerceActive() ||
! apply_filters( 'aioseo_sitemap_woocommerce_exclude_hidden_products', true )
) {
return $query;
}
static $hiddenProductIds = null;
if ( null === $hiddenProductIds ) {
$tempDb = new CommonUtils\Database();
$hiddenProducts = $tempDb->start( 'term_relationships as tr' )
->select( 'tr.object_id' )
->join( 'term_taxonomy as tt', 'tr.term_taxonomy_id = tt.term_taxonomy_id' )
->join( 'terms as t', 'tt.term_id = t.term_id' )
->where( 't.name', 'exclude-from-catalog' )
->run()
->result();
if ( empty( $hiddenProducts ) ) {
return $query;
}
$hiddenProductIds = [];
foreach ( $hiddenProducts as $hiddenProduct ) {
$hiddenProductIds[] = (int) $hiddenProduct->object_id;
}
$hiddenProductIds = esc_sql( implode( ', ', $hiddenProductIds ) );
}
$query->whereRaw( "p.ID NOT IN ( $hiddenProductIds )" );
return $query;
}
/**
* Filters the queried posts.
*
* @since 4.0.0
*
* @param array $posts The posts.
* @return array $remainingPosts The remaining posts.
*/
public function filterPosts( $posts ) {
$remainingPosts = [];
foreach ( $posts as $post ) {
switch ( $post->post_type ) {
case 'attachment':
if ( ! $this->isInvalidAttachment( $post ) ) {
$remainingPosts[] = $post;
}
break;
default:
$remainingPosts[] = $post;
break;
}
}
return $remainingPosts;
}
/**
* Excludes attachments if their post parent isn't published or parent post type isn't registered anymore.
*
* @since 4.0.0
*
* @param Object $post The post.
* @return boolean Whether the attachment is invalid.
*/
private function isInvalidAttachment( $post ) {
if ( empty( $post->post_parent ) ) {
return false;
}
$parent = get_post( $post->post_parent );
if ( ! is_object( $parent ) ) {
return false;
}
if (
'publish' !== $parent->post_status ||
! in_array( $parent->post_type, get_post_types(), true ) ||
$parent->post_password
) {
return true;
}
return false;
}
/**
* Returns all eligble sitemap entries for a given taxonomy.
*
* @since 4.0.0
*
* @param string $taxonomy The taxonomy.
* @param array $additionalArgs Any additional arguments for the term query.
* @return array|int The term objects or the term count.
*/
public function terms( $taxonomy, $additionalArgs = [] ) {
// Set defaults.
$fields = 't.term_id';
$offset = aioseo()->sitemap->offset;
// Override defaults if passed as additional arg.
foreach ( $additionalArgs as $name => $value ) {
$$name = esc_sql( $value );
if ( 'root' === $name && $value ) {
$fields = 't.term_id';
}
if ( 'count' === $name && $value ) {
$fields = 'count(t.term_id) as total';
}
}
$termRelationshipsTable = aioseo()->core->db->db->prefix . 'term_relationships';
$termTaxonomyTable = aioseo()->core->db->db->prefix . 'term_taxonomy';
$query = aioseo()->core->db
->start( aioseo()->core->db->db->terms . ' as t', true )
->select( $fields )
->whereRaw( "
( `t`.`term_id` IN
(
SELECT `tt`.`term_id`
FROM `$termTaxonomyTable` as tt
WHERE `tt`.`taxonomy` = '$taxonomy'
AND `tt`.`count` > 0
)
)" );
$excludedTerms = aioseo()->sitemap->helpers->excludedTerms();
if ( $excludedTerms ) {
$query->whereRaw("
( `t`.`term_id` NOT IN
(
SELECT `tr`.`term_taxonomy_id`
FROM `$termRelationshipsTable` as tr
WHERE `tr`.`term_taxonomy_id` IN ( $excludedTerms )
)
)" );
}
if (
aioseo()->sitemap->indexes &&
empty( $additionalArgs['root'] ) &&
( empty( $additionalArgs['count'] ) || ! $additionalArgs['count'] )
) {
$query->limit( aioseo()->sitemap->linksPerIndex, $offset );
}
// Return the total if we are just counting the terms.
if ( ! empty( $additionalArgs['count'] ) && $additionalArgs['count'] ) {
return (int) $query->run( true, 'var' )
->result();
}
$terms = $query->orderBy( '`t`.`term_id` ASC' )
->run()
->result();
foreach ( $terms as $term ) {
// Convert ID from string to int.
$term->term_id = (int) $term->term_id;
// Add taxonomy name to object manually instead of querying it to prevent redundant join.
$term->taxonomy = $taxonomy;
}
return $terms;
}
/**
* Wipes all data and forces the plugin to rescan the site for images.
*
* @since 4.0.13
*
* @return void
*/
public function resetImages() {
aioseo()->core->db
->update( 'aioseo_posts' )
->set(
[
'images' => null,
'image_scan_date' => null
]
)
->run();
}
}
Fatal error: Uncaught Error: Class "AIOSEO\Plugin\Common\Sitemap\Query" not found in /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/app/Pro/Sitemap/Query.php:16
Stack trace:
#0 /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/vendor/composer/ClassLoader.php(576): include()
#1 /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/vendor/composer/ClassLoader.php(427): Composer\Autoload\{closure}('/home/valigeria...')
#2 /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/app/Pro/Sitemap/Sitemap.php(33): Composer\Autoload\ClassLoader->loadClass('AIOSEO\\Plugin\\P...')
#3 /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/app/AIOSEO.php(311): AIOSEO\Plugin\Pro\Sitemap\Sitemap->__construct()
#4 /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/app/AIOSEO.php(97): AIOSEO\Plugin\AIOSEO->load()
#5 /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/app/AIOSEO.php(76): AIOSEO\Plugin\AIOSEO->init()
#6 /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/app/AIOSEO.php(414): AIOSEO\Plugin\AIOSEO::instance()
#7 /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/all_in_one_seo_pack.php(96): aioseo()
#8 /home/valigeria/public_html/wp-settings.php(517): include_once('/home/valigeria...')
#9 /home/valigeria/public_html/wp-config.php(111): require_once('/home/valigeria...')
#10 /home/valigeria/public_html/wp-load.php(50): require_once('/home/valigeria...')
#11 /home/valigeria/public_html/wp-blog-header.php(13): require_once('/home/valigeria...')
#12 /home/valigeria/public_html/index.php(17): require('/home/valigeria...')
#13 {main}
thrown in /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/app/Pro/Sitemap/Query.php on line 16