Skip to content

Commit

Permalink
Attempt to fix edit entry link cache
Browse files Browse the repository at this point in the history
`wp_cache_get()` is normally not persistent (only caches for life of
the request), but caching plugins can modify that behavior.

I'm not able to reproduce the issue, can you test this, @jakejackson1 ?

Fixes #887
  • Loading branch information
zackkatz committed May 17, 2017
1 parent 50ac652 commit 92f8b15
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions includes/class-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,10 @@ public static function directory_link( $post_id = NULL, $add_query_args = true )
// @since 1.3
$link = wp_cache_get( 'gv_directory_link_'.$post_id );

if( $post_id === get_option( 'page_on_front' ) ) {
$link = home_url();
}

if( empty( $link ) ) {

$link = get_permalink( $post_id );
Expand Down

3 comments on commit 92f8b15

@jakejackson1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Zack. It's on my list of things to test.

@jakejackson1
Copy link
Collaborator

@jakejackson1 jakejackson1 commented on 92f8b15 Jun 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. I've tested this patch out and verified it functions correctly.

If you wanted you could actually do this: if( empty( $link ) || $post_id === get_option( 'page_on_front' ) ) { instead of adding a separate IF statement.

@zackkatz
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Jake! I've moved to preferring more if() logic blocks than requiring devs to figure out more complex statements.

I'm planning on releasing an update within a week.

Please sign in to comment.