$meta_id Unused — present for hook-signature compatibility * (`deleted_post_meta` passes an array of ids). */ public function clear_post_cache_for_meta( $meta_id, int $post_id, string $meta_key ): void { if ( ! isset( MetaFields::definitions()[ $meta_key ] ) ) { return; } $this->clear_post_cache( $post_id ); } /** * Term-side counterpart of clear_post_cache_for_meta(). * * @param int|array $meta_id Unused — see clear_post_cache_for_meta(). */ public function clear_term_cache_for_meta( $meta_id, int $term_id, string $meta_key ): void { if ( ! isset( TermMetaFields::definitions()[ $meta_key ] ) ) { return; } $this->clear_term_cache( $term_id ); } public function clear_post_cache( int $post_id ): void { // `save_post` fires for every autosave and revision too (both are // real rows in wp_posts) — neither reflects the published, publicly // visible state of the post, so clearing caches for them (especially // the post-type-wide sitemap-exclusion aggregate below, expensive to // rebuild) would just be invalidation noise on every autosave tick // while someone has the editor open. if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) { return; } // Must match the key format SchemaOutput::cached_json() stores under, // and go through GraphCache — that class falls back to a TRANSIENT // when the site has no persistent object cache (the common case on // shared hosting), so a bare wp_cache_delete() here cleared an // already-empty per-request bucket and left the real entry in place // for the full hour. GraphCache::delete( sprintf( 'graph_%d_v%d', $post_id, CacheVersion::get() ) ); // The sitemap exclusion list is a post-type-level aggregate (SitemapExclusion), // so a single post's robots setting changing must also clear that aggregate — // otherwise a post's index/noindex change wouldn't be reflected in the sitemap // until something else happens to bump the global CacheVersion. $post = get_post( $post_id ); if ( $post instanceof \WP_Post ) { wp_cache_delete( sprintf( 'sitemap_excluded_%s_v%d', $post->post_type, CacheVersion::get() ), self::CACHE_GROUP ); } } public function clear_term_cache( int $term_id ): void { // Must match the key format TermSchemaOutput::cached_json() stores under // — same transient-fallback reason as clear_post_cache() above. GraphCache::delete( sprintf( 'term_graph_%d_v%d', $term_id, CacheVersion::get() ) ); } public function maybe_bump_version( string $option ): void { if ( 0 !== strpos( $option, 'acez_seo_' ) || 'acez_seo_cache_version' === $option ) { return; } /** * Operational-state options (queues, logs, counters) change often and * never affect front-end output — bumping the global cache version * for them would keep the JSON-LD cache permanently cold (e.g. the * Pro bulk queue writes its job state on every batch). * * @param string[] $excluded Option names that must NOT bump the version. */ $excluded = apply_filters( 'acez_seo_cache_bump_excluded_options', array( 'acez_seo_ai_usage', 'acez_seo_ai_log' ) ); if ( in_array( $option, $excluded, true ) ) { return; } CacheVersion::bump(); } }