diff --git src/includes/core/actions.php src/includes/core/actions.php
index 40f9dd4..5231a9c 100644
|
|
add_action( 'bbp_new_reply_pre_extras', 'bbp_clean_post_cache' ); |
295 | 295 | add_action( 'bbp_new_reply_post_extras', 'bbp_clean_post_cache' ); |
296 | 296 | |
297 | 297 | // Clean bbPress post caches when WordPress's is cleaned |
298 | | add_action( 'clean_post_cache', 'bbp_clean_post_cache' ); |
| 298 | add_action( 'clean_post_cache', 'bbp_clean_post_cache', 10, 2 ); |
299 | 299 | |
300 | 300 | /** |
301 | 301 | * bbPress needs to redirect the user around in a few different circumstances: |
diff --git src/includes/core/cache.php src/includes/core/cache.php
index 4734d13..f703dbe 100644
|
|
new BBP_Skip_Children(); |
130 | 130 | * |
131 | 131 | * @since bbPress (r4040) |
132 | 132 | * |
| 133 | * @param mixed $post The post object or ID to remove from the cache. Defaults to null. |
| 134 | * @param mixed $post_object The post object to remove from the cache. Defaults to null. |
| 135 | * @uses get_post() To get the post object. |
| 136 | * @uses bbp_get_forum_post_type() To get the forum post type. |
| 137 | * @uses bbp_get_topic_post_type() To get the topic post type. |
| 138 | * @uses bbp_get_reply_post_type() To get the reply post type. |
| 139 | * @uses wp_cache_delete() To delete the cache item. |
| 140 | * @uses clean_object_term_cache() To clean the term cache. |
| 141 | * @uses bbp_clean_post_cache() Recursion. |
133 | 142 | * @uses do_action() Calls 'bbp_clean_post_cache' on $id |
134 | | * @param object|int $_post The post object or ID to remove from the cache |
135 | 143 | */ |
136 | | function bbp_clean_post_cache( $_post = '' ) { |
| 144 | function bbp_clean_post_cache( $post = null, $post_object = null ) { |
| 145 | |
| 146 | // Make sure $post_object is a WP_Post object |
| 147 | if ( $post_object instanceof WP_Post ) { |
| 148 | $post = $post_object; |
| 149 | } |
137 | 150 | |
138 | 151 | // Bail if no post |
139 | | $_post = get_post( $_post ); |
140 | | if ( empty( $_post ) ) { |
| 152 | $post = get_post( $post ); |
| 153 | if ( empty( $post ) ) { |
141 | 154 | return; |
142 | 155 | } |
143 | 156 | |
… |
… |
function bbp_clean_post_cache( $_post = '' ) { |
149 | 162 | ); |
150 | 163 | |
151 | 164 | // Bail if not a bbPress post type |
152 | | if ( ! in_array( $_post->post_type, $post_types, true ) ) { |
| 165 | if ( ! in_array( $post->post_type, $post_types, true ) ) { |
153 | 166 | return; |
154 | 167 | } |
155 | 168 | |
156 | | wp_cache_delete( $_post->ID, 'posts' ); |
157 | | wp_cache_delete( $_post->ID, 'post_meta' ); |
| 169 | wp_cache_delete( $post->ID, 'posts' ); |
| 170 | wp_cache_delete( $post->ID, 'post_meta' ); |
158 | 171 | |
159 | | clean_object_term_cache( $_post->ID, $_post->post_type ); |
| 172 | clean_object_term_cache( $post->ID, $post->post_type ); |
160 | 173 | |
161 | | do_action( 'bbp_clean_post_cache', $_post->ID, $_post ); |
| 174 | do_action( 'bbp_clean_post_cache', $post->ID, $post ); |
162 | 175 | |
163 | 176 | // Loop through query types and clean caches |
164 | 177 | foreach ( $post_types as $post_type ) { |
165 | | wp_cache_delete( 'bbp_get_forum_' . $_post->ID . '_reply_id', 'bbpress_posts' ); |
166 | | wp_cache_delete( 'bbp_parent_' . $_post->ID . '_type_' . $post_type . '_child_last_id', 'bbpress_posts' ); |
167 | | wp_cache_delete( 'bbp_parent_' . $_post->ID . '_type_' . $post_type . '_child_count', 'bbpress_posts' ); |
168 | | wp_cache_delete( 'bbp_parent_public_' . $_post->ID . '_type_' . $post_type . '_child_ids', 'bbpress_posts' ); |
169 | | wp_cache_delete( 'bbp_parent_all_' . $_post->ID . '_type_' . $post_type . '_child_ids', 'bbpress_posts' ); |
| 178 | wp_cache_delete( 'bbp_get_forum_' . $post->ID . '_reply_id', 'bbpress_posts' ); |
| 179 | wp_cache_delete( 'bbp_parent_' . $post->ID . '_type_' . $post_type . '_child_last_id', 'bbpress_posts' ); |
| 180 | wp_cache_delete( 'bbp_parent_' . $post->ID . '_type_' . $post_type . '_child_count', 'bbpress_posts' ); |
| 181 | wp_cache_delete( 'bbp_parent_public_' . $post->ID . '_type_' . $post_type . '_child_ids', 'bbpress_posts' ); |
| 182 | wp_cache_delete( 'bbp_parent_all_' . $post->ID . '_type_' . $post_type . '_child_ids', 'bbpress_posts' ); |
170 | 183 | } |
171 | 184 | |
172 | 185 | // Invalidate parent caches |
173 | | if ( ! empty( $_post->post_parent ) ) { |
174 | | bbp_clean_post_cache( $_post->post_parent ); |
| 186 | if ( ! empty( $post->post_parent ) ) { |
| 187 | bbp_clean_post_cache( $post->post_parent ); |
175 | 188 | } |
176 | 189 | } |