-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathvipgo-helper.php
More file actions
36 lines (33 loc) · 1.14 KB
/
vipgo-helper.php
File metadata and controls
36 lines (33 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
* VIP Go Helper file.
*
* This file is automatically loaded by the VIP Go platform and contains
* VIP-specific enhancements.
*
* @see https://docs.wpvip.com/plugins/helper-file/
* @package Automattic\Liveblog
*/
/**
* Purge the VIP edge cache for a liveblog when entries change.
*
* Ensures that a Liveblog page isn't cached with stale metadata during an
* active liveblog. This is particularly important for SEO and social sharing
* where the page's cached version may contain outdated entry counts or timestamps.
*
* @param int $comment_id ID of the comment for this entry.
* @param int $post_id ID for this liveblog post.
*/
function liveblog_purge_edge_cache( $comment_id, $post_id ) {
if ( ! function_exists( 'wpcom_vip_purge_edge_cache_for_url' ) ) {
return;
}
$permalink = get_permalink( absint( $post_id ) );
if ( ! $permalink ) {
return;
}
wpcom_vip_purge_edge_cache_for_url( $permalink );
}
add_action( 'liveblog_insert_entry', 'liveblog_purge_edge_cache', 10, 2 );
add_action( 'liveblog_update_entry', 'liveblog_purge_edge_cache', 10, 2 );
add_action( 'liveblog_delete_entry', 'liveblog_purge_edge_cache', 10, 2 );