$filename = "$postType-$sitemapName.xml";
$files[ $filename ] = [
'total' => $total,
'entries' => $chunks[0]
];
} else {
for ( $i = 1; $i <= count( $chunks ); $i++ ) {
$filename = "$postType-$sitemapName$i.xml";
$files[ $filename ] = [
'total' => $total,
'entries' => $chunks[ $i - 1 ]
];
}
}
}
}
$taxonomies = aioseo()->sitemap->helpers->includedTaxonomies();
if ( $taxonomies ) {
foreach ( $taxonomies as $taxonomy ) {
aioseo()->sitemap->indexName = $taxonomy;
$terms = aioseo()->sitemap->content->terms( $taxonomy );
if ( ! $terms ) {
continue;
}
$total = aioseo()->sitemap->query->terms( $taxonomy, [ 'count' => true ] );
// We need to temporarily reset the linksPerIndex count here so that we can properly chunk.
aioseo()->sitemap->linksPerIndex = aioseo()->options->sitemap->general->linksPerIndex;
$chunks = aioseo()->sitemap->helpers->chunkEntries( $terms );
aioseo()->sitemap->linksPerIndex = PHP_INT_MAX;
if ( 1 === count( $chunks ) ) {
$filename = "$taxonomy-$sitemapName.xml";
$files[ $filename ] = [
'total' => $total,
'entries' => $chunks[0]
];
} else {
for ( $i = 1; $i <= count( $chunks ); $i++ ) {
$filename = "$taxonomy-$sitemapName$i.xml";
$files[ $filename ] = [
'total' => $total,
'entries' => $chunks[ $i - 1 ]
];
}
}
}
}
$this->writeSitemaps( $files );
}
/**
* Writes all sitemap files.
*
* @since 4.0.0
*
* @param array $files The sitemap files.
* @return void
*/
public function writeSitemaps( $files ) {
$sitemapName = aioseo()->sitemap->helpers->filename();
if ( aioseo()->sitemap->indexes ) {
$indexes = [];
foreach ( $files as $filename => $data ) {
if ( empty( $data['entries'] ) ) {
continue;
}
$indexes[] = [
'loc' => trailingslashit( home_url() ) . $filename,
'lastmod' => array_values( $data['entries'] )[0]['lastmod'],
'count' => count( $data['entries'] )
];
}
$files[ "$sitemapName.xml" ] = [
'total' => 0,
'entries' => $indexes,
];
foreach ( $files as $filename => $data ) {
$this->writeSitemap( $filename, $data['entries'], $data['total'] );
}
return;
}
$content = [];
foreach ( $files as $filename => $data ) {
foreach ( $data['entries'] as $entry ) {
$content[] = $entry;
}
}
$this->writeSitemap( "$sitemapName.xml", $content, count( $content ) );
}
/**
* Writes a given sitemap file to the root dir.
*
* Helper function for writeSitemaps().
*
* @since 4.0.0
*
* @param string $filename The name of the file.
* @param array $entries The sitemap entries for the file.
* @return void
*/
protected function writeSitemap( $filename, $entries, $total = 0 ) {
$sitemapName = aioseo()->sitemap->helpers->filename();
aioseo()->sitemap->indexName = $filename;
if ( "$sitemapName.xml" === $filename && aioseo()->sitemap->indexes ) {
// Set index name to root so that we use the right output template.
aioseo()->sitemap->indexName = 'root';
}
aioseo()->sitemap->xsl->saveXslData( $filename, $entries, $total );
ob_start();
aioseo()->sitemap->output->output( $entries );
aioseo()->addons->doAddonFunction( 'output', 'output', [ $entries, $total ] );
$content = ob_get_clean();
$fs = aioseo()->core->fs;
$file = ABSPATH . sanitize_file_name( $filename );
$fileExists = $fs->exists( $file );
if ( ! $fileExists || $fs->isWritable( $file ) ) {
$fs->putContents( $file, $content );
}
}
/**
* Return an array of sitemap files.
*
* @since 4.0.0
*
* @return array An array of files.
*/
public function files() {
require_once ABSPATH . 'wp-admin/includes/file.php';
$files = list_files( get_home_path(), 1 );
if ( ! count( $files ) ) {
return [];
}
$sitemapFiles = [];
foreach ( $files as $filename ) {
if ( preg_match( '#.*sitemap.*#', $filename ) ) {
$sitemapFiles[] = $filename;
}
}
return $sitemapFiles;
}
}
Fatal error: Uncaught Error: Class "AIOSEO\Plugin\Common\Sitemap\File" not found in /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/app/Pro/Sitemap/Sitemap.php:28
Stack trace:
#0 /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/app/AIOSEO.php(311): AIOSEO\Plugin\Pro\Sitemap\Sitemap->__construct()
#1 /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/app/AIOSEO.php(97): AIOSEO\Plugin\AIOSEO->load()
#2 /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/app/AIOSEO.php(76): AIOSEO\Plugin\AIOSEO->init()
#3 /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/app/AIOSEO.php(414): AIOSEO\Plugin\AIOSEO::instance()
#4 /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/all_in_one_seo_pack.php(96): aioseo()
#5 /home/valigeria/public_html/wp-settings.php(517): include_once('/home/valigeria...')
#6 /home/valigeria/public_html/wp-config.php(111): require_once('/home/valigeria...')
#7 /home/valigeria/public_html/wp-load.php(50): require_once('/home/valigeria...')
#8 /home/valigeria/public_html/wp-blog-header.php(13): require_once('/home/valigeria...')
#9 /home/valigeria/public_html/index.php(17): require('/home/valigeria...')
#10 {main}
thrown in /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/app/Pro/Sitemap/Sitemap.php on line 28