Improve author array validation
This commit is contained in:
parent
ef5b584241
commit
6aae419a27
@ -144,6 +144,10 @@ if ( ! function_exists( 'fictioneer_get_author_node' ) ) {
|
||||
$author_name = get_the_author_meta( 'display_name', $author_id );
|
||||
$author_url = get_author_posts_url( $author_id );
|
||||
|
||||
if ( ! $author_name ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return "<a href='{$author_url}' class='author {$classes}'>{$author_name}</a>";
|
||||
}
|
||||
}
|
||||
@ -531,6 +535,9 @@ if ( ! function_exists( 'fictioneer_get_multi_author_nodes' ) ) {
|
||||
$author_nodes[] = fictioneer_get_author_node( $author );
|
||||
}
|
||||
|
||||
// Remove empty items
|
||||
$author_nodes = array_filter( $author_nodes );
|
||||
|
||||
// Build and return HTML
|
||||
return implode( ', ', array_unique( $author_nodes ) );
|
||||
}
|
||||
|
@ -711,6 +711,9 @@ function fictioneer_save_story_metabox( $post_id ) {
|
||||
|
||||
$co_authors = fictioneer_explode_list( $_POST['fictioneer_story_co_authors'] ?? '' );
|
||||
$co_authors = array_map( 'absint', $co_authors );
|
||||
$co_authors = array_filter ($co_authors, function( $user_id ) {
|
||||
return get_userdata( $user_id ) !== false;
|
||||
});
|
||||
$fields['fictioneer_story_co_authors'] = array_unique( $co_authors );
|
||||
|
||||
if ( current_user_can( 'fcn_make_sticky', $post_id ) && FICTIONEER_ENABLE_STICKY_CARDS ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user