Plugin Directory

Changeset 1538704


Ignore:
Timestamp:
11/22/2016 10:05:48 PM (9 years ago)
Author:
andy
Message:

batcache: Don't use get_post() when cleaning post cache, use already passed $post object

https://github.com/Automattic/batcache/pull/77

File:
1 edited

Legend:

Unmodified
Added
Removed
  • batcache/trunk/batcache.php

    r1300303 r1538704  
    1616
    1717// Regen home and permalink on posts and pages
    18 add_action('clean_post_cache', 'batcache_post');
     18add_action('clean_post_cache', 'batcache_post', 10, 2);
    1919
    2020// Regen permalink on comments (TODO)
     
    2323//add_action('edit_comment',          'batcache_comment');
    2424
    25 function batcache_post($post_id) {
     25function batcache_post($post_id, $post = null) {
    2626    global $batcache;
    2727
    28     $post = get_post($post_id);
    29     if ( $post->post_type == 'revision' || ! in_array( get_post_status($post_id), array( 'publish', 'trash' ) ) )
     28    // Get the post for backwards compatibility with earlier versions of WordPress
     29    if ( ! $post ) {
     30        $post = get_post( $post_id );   
     31    }
     32   
     33    if ( ! $post || $post->post_type == 'revision' || ! in_array( get_post_status($post_id), array( 'publish', 'trash' ) ) )
    3034        return;
    3135
Note: See TracChangeset for help on using the changeset viewer.