Skip to main content

GravityView_Sharing_Sitemaps

Keep embed-only Views out of XML sitemaps.

A View with "Prevent Direct Access" (the embed_only setting) enabled is not meant to be reached at its own URL, so its URL must not be advertised to crawlers. Covers Yoast SEO, WordPress core sitemaps, Rank Math, and AIOSEO.

Since: 3.4

Source: includes/class-gravityview-sharing-sitemaps.php:11

Details

  • Kind: class
  • Namespace: (global)

Methods

MethodDescription
get_instance()
add_hooks()Register sitemap filters for each SEO system and cache-invalidation hooks.
gravityview_handles_core_sitemaps()Whether GravityView already keeps these Views out of the WordPress core sitemap.
get_embed_only_view_ids()IDs of published Views that have the embed_only setting enabled.
yoast_exclude_post_ids()Yoast SEO. Runs inside get_excluded_posts(); Yoast intval()s and de-duplicates the result.
core_sitemap_query_args()WordPress core sitemaps. Only touches the gravityview provider's query.
rank_math_where()Rank Math. Appends to the WHERE fragment of both the URL query and the count query;
aioseo_exclude_post_ids()All in One SEO.
jetpack_skip_post()Jetpack. Per-post skip for its Sitemaps module.
seo_framework_exclude_ids()The SEO Framework. Sequential array of post IDs to exclude.
slim_seo_ignore_post()Slim SEO. Per-post ignore.
seopress_query_args()SEOPress. Filters the get_posts() args for a single post type's sitemap.
smartcrawl_ignored_ids()SmartCrawl. IDs to ignore for this post type's sitemap.
maybe_flush_cache_on_meta()Flush the cached list when the View settings meta changes.
flush_cache()

Method Reference

get_instance()

public static function get_instance()

Returns

Source: includes/class-gravityview-sharing-sitemaps.php:51

add_hooks()

public function add_hooks()

Register sitemap filters for each SEO system and cache-invalidation hooks.

Returns

  • void

Source: includes/class-gravityview-sharing-sitemaps.php:69

gravityview_handles_core_sitemaps()

public static function gravityview_handles_core_sitemaps()

Whether GravityView already keeps these Views out of the WordPress core sitemap.

It does so from the release that added \GV\View's DirectAccess handling, and that is the better place for it: core sitemaps ship with WordPress, so leaving them to this extension would cover only the small share of GravityView sites that run it. Registering here as well would just run the same lookup twice per sitemap request.

Older GravityView has no such handling, so this plugin still covers core sitemaps there — a site that updates this extension but not GravityView is not left exposed.

Returns

  • bool

Source: includes/class-gravityview-sharing-sitemaps.php:123

get_embed_only_view_ids()

public function get_embed_only_view_ids()

IDs of published Views that have the embed_only setting enabled.

Two queries (post IDs, then one meta-cache prime) per cache miss; otherwise a transient read.

Returns

  • int[]

Source: includes/class-gravityview-sharing-sitemaps.php:135

yoast_exclude_post_ids()

public function yoast_exclude_post_ids( $excluded_ids )

Yoast SEO. Runs inside get_excluded_posts(); Yoast intval()s and de-duplicates the result.

Parameters

NameTypeDefaultDescription
$excluded_idsarrayPost IDs Yoast already excludes (e.g. page_on_front).

Returns

  • array

Source: includes/class-gravityview-sharing-sitemaps.php:189

core_sitemap_query_args()

public function core_sitemap_query_args( $args, $post_type )

WordPress core sitemaps. Only touches the gravityview provider's query.

Parameters

NameTypeDefaultDescription
$argsarrayWP_Query arguments.
$post_typestringPost type being rendered.

Returns

  • array

Source: includes/class-gravityview-sharing-sitemaps.php:204

rank_math_where()

public function rank_math_where( $where, $post_types )

Rank Math. Appends to the WHERE fragment of both the URL query and the count query;

both alias the posts table as p. $post_types is a single post type string despite the upstream docblock.

Parameters

NameTypeDefaultDescription
$wherestringExisting WHERE fragment (empty by default).
$post_typesstring | arrayPost type being rendered.

Returns

  • string

Source: includes/class-gravityview-sharing-sitemaps.php:233

aioseo_exclude_post_ids()

public function aioseo_exclude_post_ids( $ids, $type='' )

All in One SEO.

$type is AIOSEO's SITEMAP type ('general', 'rss', ...), NOT a post type — it indexes aioseo()->options->sitemap->{$type}->advancedSettings (Common/Sitemap/Helpers.php). So there is nothing to scope on here, and nothing to scope for: the IDs are Views, which belong in no sitemap AIOSEO builds. Verified against AIOSEO 5.0.1.1 by fetching the real sitemap; an earlier version of this method compared $type to the post type and therefore never excluded anything.

Merely registering this filter also matters: AIOSEO short-circuits the whole exclusion query with return '' unless a site has advanced settings, existing exclusions, or has_filter( 'aioseo_sitemap_exclude_posts' ) is true.

Parameters

NameTypeDefaultDescription
$idsarrayPost IDs AIOSEO already excludes.
$typestring''AIOSEO sitemap type ('general', 'rss', ...). Unused; see above.

Returns

  • array

Source: includes/class-gravityview-sharing-sitemaps.php:272

jetpack_skip_post()

public function jetpack_skip_post( $skip, $post )

Jetpack. Per-post skip for its Sitemaps module.

$post is NOT a WP_Post — Jetpack passes a raw $wpdb result object carrying only some properties (sitemap-builder.php), so read nothing beyond the ID.

Parameters

NameTypeDefaultDescription
$skipboolWhether Jetpack already decided to skip this post.
$postobjectPartial post object from Jetpack's own query.

Returns

  • bool

Source: includes/class-gravityview-sharing-sitemaps.php:290

seo_framework_exclude_ids()

public function seo_framework_exclude_ids( $excluded_ids )

The SEO Framework. Sequential array of post IDs to exclude.

TSF memoizes and array_flip()s this once per request, so it is called a single time.

Parameters

NameTypeDefaultDescription
$excluded_idsarrayIDs already excluded.

Returns

  • array

Source: includes/class-gravityview-sharing-sitemaps.php:308

slim_seo_ignore_post()

public function slim_seo_ignore_post( $ignore, $post )

Slim SEO. Per-post ignore.

Parameters

NameTypeDefaultDescription
$ignoreboolWhether Slim SEO already decided to ignore this post.
$post\WP_PostThe post being considered.

Returns

  • bool

Source: includes/class-gravityview-sharing-sitemaps.php:323

seopress_query_args()

public function seopress_query_args( $args, $path )

SEOPress. Filters the get_posts() args for a single post type's sitemap.

SEOPress exposes no post-level exclusion filter; this is the query that builds the post-type sitemap (templates/sitemap/single.php). $path is the post type.

Parameters

NameTypeDefaultDescription
$argsarrayget_posts() arguments.
$pathstringPost type being rendered.

Returns

  • array

Source: includes/class-gravityview-sharing-sitemaps.php:343

smartcrawl_ignored_ids()

public function smartcrawl_ignored_ids( $ignored_ids )

SmartCrawl. IDs to ignore for this post type's sitemap.

The hook name is dynamic — wds_sitemap_ignored_{$post_type}_ids — so it is already scoped to Views and needs no post-type check of its own.

Parameters

NameTypeDefaultDescription
$ignored_idsarrayIDs SmartCrawl already ignores.

Returns

  • array

Source: includes/class-gravityview-sharing-sitemaps.php:372

maybe_flush_cache_on_meta()

public function maybe_flush_cache_on_meta( $meta_id, $object_id, $meta_key )

Flush the cached list when the View settings meta changes.

Parameters

NameTypeDefaultDescription
$meta_idint | int[]Meta row ID(s). Unused.
$object_idintPost ID.
$meta_keystringMeta key.

Returns

  • void

Source: includes/class-gravityview-sharing-sitemaps.php:388

flush_cache()

public function flush_cache()

Returns

  • void

Source: includes/class-gravityview-sharing-sitemaps.php:400