Skip to content
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

Guest author links should be filterable #204

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions php/class-coauthors-guest-authors.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function filter_post_updated_messages( $messages ) {
global $post;

$guest_author = $this->get_guest_author_by( 'ID', $post->ID );
$guest_author_link = $this->filter_author_link( '', $guest_author->ID, $guest_author->user_nicename );
$guest_author_link = get_author_posts_url( $guest_author->ID, $guest_author->user_nicename );

$messages[$this->post_type] = array(
0 => '', // Unused. Messages start at index 1.
Expand Down Expand Up @@ -1319,23 +1319,14 @@ function filter_author_link( $link, $author_id, $author_nicename ) {

// If we're using this at the top of the loop on author.php,
// our queried object should be set correctly
if ( !$author_nicename && is_author() && get_queried_object() )
if ( !$author_nicename && is_author() && get_queried_object() ) {
$author_nicename = get_queried_object()->user_nicename;

if ( empty($link) ) {
$link = add_query_arg( 'author_name', $author_nicename, home_url() );
} else {
global $wp_rewrite;
$link = $wp_rewrite->get_author_permastruct();
if ( $link ) {
$link = str_replace('%author%', $author_nicename, $link);
$link = home_url( user_trailingslashit( $link ) );
} else {
$link = add_query_arg( 'author_name', $author_nicename, home_url() );
}
// Use get_author_posts_url() so we have access to the author_link filter
$link = get_author_posts_url( $author_id, $author_nicename );
}
return $link;

return $link;
}

/**
Expand Down