New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix: Co-Author Order Not Retained in WordPress 4.7 #391

Merged
merged 3 commits into from Mar 11, 2017
Jump to file or symbol
Failed to load files and symbols.
+17 −2
Diff settings

Always

Just for now

View
@@ -116,6 +116,9 @@ function __construct() {
// Support infinite scroll for Guest Authors on author pages
add_filter( 'infinite_scroll_js_settings', array( $this, 'filter_infinite_scroll_js_settings' ), 10, 2 );
// Delete CoAuthor Cache on Post Save & Post Delete
add_action( 'save_post', array( $this, 'clear_cache') );
add_action( 'delete_post', array( $this, 'clear_cache') );
}
/**
@@ -1469,6 +1472,15 @@ public function filter_jetpack_open_graph_tags( $og_tags, $image_dimensions ) {
// Send back the updated Open Graph Tags
return apply_filters( 'coauthors_open_graph_tags', $og_tags );
}
/**
* Callback to clear the cache on post save and post delete.
*
* @param $post_id The Post ID.
*/
public function clear_cache( $post_id ) {
wp_cache_delete( 'coauthors_post_' . $post_id );

This comment has been minimized.

@goldenapples

goldenapples Jan 19, 2017

I believe that this call to wp_cache_delete will need to pass the cache group 'co-authors-plus' as its second argument, in order to ensure that it is cleared properly - since the cache item was added in the 'co-authors-plus' cache group.

@goldenapples

goldenapples Jan 19, 2017

I believe that this call to wp_cache_delete will need to pass the cache group 'co-authors-plus' as its second argument, in order to ensure that it is cleared properly - since the cache item was added in the 'co-authors-plus' cache group.

This comment has been minimized.

@mslinnea

mslinnea Feb 25, 2017

Good spot!

@mslinnea
}
}
global $coauthors_plus;
View
@@ -14,8 +14,11 @@ function get_coauthors( $post_id = 0 ) {
}
if ( $post_id ) {
$coauthor_terms = get_the_terms( $post_id, $coauthors_plus->coauthor_taxonomy );
$cache_key = 'coauthors_post_' . $post_id;
if ( false === ( $coauthor_terms = wp_cache_get( $cache_key, 'co-authors-plus' ) ) ) {
$coauthor_terms = wp_get_object_terms( $post_id, $coauthors_plus->coauthor_taxonomy, array( 'orderby' => 'term_order', 'order' => 'ASC' ) );
wp_cache_set( $cache_key, $coauthor_terms, 'co-authors-plus' );
}
if ( is_array( $coauthor_terms ) && ! empty( $coauthor_terms ) ) {
foreach ( $coauthor_terms as $coauthor ) {
$coauthor_slug = preg_replace( '#^cap\-#', '', $coauthor->slug );