Merged in feature/314-dev-dev01 (pull request #24)

auto-patch  314-dev-dev01-2024-01-25T04_09_02

* auto-patch  314-dev-dev01-2024-01-25T04_09_02
This commit is contained in:
Tony Volpe
2024-01-25 04:11:47 +00:00
parent 6b67473553
commit 68dbe860e9
540 changed files with 3445 additions and 2131 deletions

View File

@@ -94,10 +94,11 @@ class WPSEO_Taxonomy_Sitemap_Provider implements WPSEO_Sitemap_Provider {
$hide_empty_tax = apply_filters( 'wpseo_sitemap_exclude_empty_terms_taxonomy', $hide_empty, $taxonomy_name );
$term_args = [
'taxonomy' => $taxonomy_name,
'hide_empty' => $hide_empty_tax,
'fields' => 'ids',
];
$taxonomy_terms = get_terms( $taxonomy_name, $term_args );
$taxonomy_terms = get_terms( $term_args );
if ( count( $taxonomy_terms ) > 0 ) {
$all_taxonomies[ $taxonomy_name ] = $taxonomy_terms;
@@ -211,24 +212,28 @@ class WPSEO_Taxonomy_Sitemap_Provider implements WPSEO_Sitemap_Provider {
$post_statuses = array_map( 'esc_sql', WPSEO_Sitemaps::get_post_statuses() );
// Grab last modified date.
$sql = "
SELECT MAX(p.post_modified_gmt) AS lastmod
FROM $wpdb->posts AS p
INNER JOIN $wpdb->term_relationships AS term_rel
ON term_rel.object_id = p.ID
INNER JOIN $wpdb->term_taxonomy AS term_tax
ON term_tax.term_taxonomy_id = term_rel.term_taxonomy_id
AND term_tax.taxonomy = %s
AND term_tax.term_id = %d
WHERE p.post_status IN ('" . implode( "','", $post_statuses ) . "')
AND p.post_password = ''
";
$replacements = array_merge(
[
'post_modified_gmt',
$wpdb->posts,
$wpdb->term_relationships,
'object_id',
'ID',
$wpdb->term_taxonomy,
'term_taxonomy_id',
'term_taxonomy_id',
'taxonomy',
'term_id',
'post_status',
],
$post_statuses,
[ 'post_password' ]
);
/**
* Filter: 'wpseo_exclude_from_sitemap_by_term_ids' - Allow excluding terms by ID.
*
* @api array $terms_to_exclude The terms to exclude.
* @param array $terms_to_exclude The terms to exclude.
*/
$terms_to_exclude = apply_filters( 'wpseo_exclude_from_sitemap_by_term_ids', [] );
@@ -253,7 +258,30 @@ class WPSEO_Taxonomy_Sitemap_Provider implements WPSEO_Sitemap_Provider {
continue;
}
$url['mod'] = $wpdb->get_var( $wpdb->prepare( $sql, $term->taxonomy, $term->term_id ) );
$current_replacements = $replacements;
array_splice( $current_replacements, 9, 0, $term->taxonomy );
array_splice( $current_replacements, 11, 0, $term->term_id );
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- We need to use a direct query here.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
$url['mod'] = $wpdb->get_var(
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
$wpdb->prepare(
'
SELECT MAX(p.%i) AS lastmod
FROM %i AS p
INNER JOIN %i AS term_rel
ON term_rel.%i = p.%i
INNER JOIN %i AS term_tax
ON term_tax.%i = term_rel.%i
AND term_tax.%i = %s
AND term_tax.%i = %d
WHERE p.%i IN (' . implode( ', ', array_fill( 0, count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
",
$current_replacements
)
);
if ( $this->include_images ) {
$url['images'] = $this->get_image_parser()->get_term_images( $term );