=> ! empty( $authorData->authorUrl ) ? $authorData->authorUrl : get_author_posts_url( $authorData->ID, $nicename ), 'lastmod' => aioseo()->helpers->dateTimeToIso8601( $authorData->lastModified ), 'changefreq' => aioseo()->sitemap->priority->frequency( 'author' ), 'priority' => aioseo()->sitemap->priority->priority( 'author' ) ]; } return apply_filters( 'aioseo_sitemap_author_archives', $entries ); } /** * Returns all data archive entries. * * @since 4.0.0 * * @return array The sitemap entries. */ public function date() { if ( ! aioseo()->sitemap->helpers->lastModifiedPost() || ! aioseo()->options->sitemap->general->date || ! aioseo()->options->searchAppearance->archives->date->show || ( ! aioseo()->options->searchAppearance->archives->date->advanced->robotsMeta->default && aioseo()->options->searchAppearance->archives->date->advanced->robotsMeta->noindex ) || ( aioseo()->options->searchAppearance->archives->date->advanced->robotsMeta->default && ( ! aioseo()->options->searchAppearance->advanced->globalRobotsMeta->default && aioseo()->options->searchAppearance->advanced->globalRobotsMeta->noindex ) ) ) { return []; } $postsTable = aioseo()->core->db->db->posts; $dates = aioseo()->core->db->execute( "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, post_date_gmt, post_modified_gmt FROM {$postsTable} WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date ASC LIMIT 50000", true )->result(); if ( empty( $dates ) ) { return []; } $entries = []; $year = ''; foreach ( $dates as $date ) { $entry = [ 'lastmod' => aioseo()->helpers->dateTimeToIso8601( $this->getLastModified( $date ) ), 'changefreq' => aioseo()->sitemap->priority->frequency( 'date' ), 'priority' => aioseo()->sitemap->priority->priority( 'date' ), ]; // Include each year only once. if ( $year !== $date->year ) { $year = $date->year; $entry['loc'] = get_year_link( $date->year ); $entries[] = $entry; } $entry['loc'] = get_month_link( $date->year, $date->month ); $entries[] = $entry; } return apply_filters( 'aioseo_sitemap_date_archives', $entries ); } /** * Returns all entries for the RSS Sitemap. * * @since 4.0.0 * * @return array The sitemap entries. */ public function rss() { $posts = aioseo()->sitemap->query->posts( aioseo()->sitemap->helpers->includedPostTypes(), [ 'orderBy' => '`p`.`post_modified_gmt` DESC' ] ); if ( ! count( $posts ) ) { return []; } $entries = []; foreach ( $posts as $post ) { $entry = [ 'guid' => get_permalink( $post->ID ), 'title' => get_the_title( $post ), 'description' => get_post_field( 'post_excerpt', $post->ID ), 'pubDate' => aioseo()->helpers->dateTimeToRfc822( $this->getLastModified( $post ) ) ]; $entries[] = apply_filters( 'aioseo_sitemap_post_rss', $entry, $post->ID, $post->post_type, 'post' ); } usort( $entries, function( $a, $b ) { return $a['pubDate'] < $b['pubDate'] ? 1 : 0; }); return apply_filters( 'aioseo_sitemap_rss', $entries ); } /** * Returns the last modified date for a given post. * * @since 4.6.3 * * @param object $post The post object. * * @return string The last modified date. */ public function getLastModified( $post ) { $publishDate = $post->post_date_gmt; $lastModifiedDate = $post->post_modified_gmt; // Get the date which is the latest. return $lastModifiedDate > $publishDate ? $lastModifiedDate : $publishDate; } }