Skip to content

Commit

Permalink
Merge pull request #1098 from INN/1097-coauthors-meta-fields
Browse files Browse the repository at this point in the history
Add job title to fields accepted by coauthors
  • Loading branch information
benlk committed Jan 26, 2016
2 parents 2f2c567 + 55119a3 commit 69629c2
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
16 changes: 15 additions & 1 deletion inc/post-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,22 @@ function largo_byline( $echo = true, $exclude_date = false, $post = null ) {

$values = get_post_custom( $post_id );

// If Co-Authors Plus is enabled
if ( function_exists( 'get_coauthors' ) && !isset( $values['largo_byline_text'] ) ) {
$coauthors = get_coauthors( $post_id );
foreach( $coauthors as $author ) {
$byline_text = $author->display_name;
$show_job_titles = of_get_option('show_job_titles');
if ( $org = $author->organization )
$byline_text .= ' (' . $org . ')';

$out[] = '<a class="url fn n" href="' . get_author_posts_url( $author->ID, $author->user_nicename ) . '" title="' . esc_attr( sprintf( __( 'Read All Posts By %s', 'largo' ), $author->display_name ) ) . '" rel="author">' . esc_html( $byline_text ) . '</a>';
$byline_temp = '<a class="url fn n" href="' . get_author_posts_url( $author->ID, $author->user_nicename ) . '" title="' . esc_attr( sprintf( __( 'Read All Posts By %s', 'largo' ), $author->display_name ) ) . '" rel="author">' . esc_html( $byline_text ) . '</a>';
if ( $show_job_titles && $job = $author->job_title ) {
// Use parentheses in case of multiple guest authorss. Comma separators would be nonsensical: Firstname lastname, Job Title, Secondname Thirdname, and Fourthname Middle Fifthname
$byline_temp .= ' (' . $job . ')';
}

$out[] = $byline_temp;

}

Expand All @@ -123,8 +131,14 @@ function largo_byline( $echo = true, $exclude_date = false, $post = null ) {
$authors = $out[0];
}

// If Co-Authors Plus is not enabled
} else {
$authors = largo_author_link( false, $post_id );
$author_id = get_post_meta( $post_id, 'post_author', true );
$show_job_titles = of_get_option('show_job_titles');
if ( $show_job_titles && $job = get_the_author_meta( 'job_title' , $author_id ) ) {
$authors .= ', ' . $job;
}
}

$output = '<span class="by-author"><span class="by">' . __( 'By', 'largo' ) . '</span> <span class="author vcard" itemprop="author">' . $authors . '</span></span>';
Expand Down
12 changes: 12 additions & 0 deletions inc/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,20 @@ function largo_filter_guest_author_fields( $fields_to_return, $groups ) {
'label' => 'Google+<br><em>https://plus.google.com/userID/</em>',
'group' => 'contact-info',
);
$fields_to_return[] = array(
'key' => 'show_email',
'label' => 'Show Email Address',
'group' => 'contact-info',
'input' => 'checkbox',
'type' => 'checkbox',
);
}
if ( in_array( 'all', $groups ) || in_array( 'name', $groups ) ) {
$fields_to_return[] = array(
'key' => 'job_title',
'label' => 'Job Title',
'group' => 'name',
);
$fields_to_return[] = array(
'key' => 'organization',
'label' => 'Organization',
Expand Down
11 changes: 11 additions & 0 deletions options.php
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,17 @@ function optionsframework_options() {
'std' => '0',
'type' => 'checkbox');

$options[] = array(
'name' => __('Byline Options', 'largo'),
'type' => 'info');

$options[] = array(
'desc' => __('Enable display of job titles in bylines and author biographies?', 'largo'),
'id' => 'show_job_titles',
'std' => '0',
'type' => 'checkbox');


/*
* Removing inn_member_since in 0.5.2
if ( INN_MEMBER ) { // only relevant in this case, options affecting the logo display
Expand Down
5 changes: 5 additions & 0 deletions partials/author-bio-description.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
echo '<div class="photo">' . $photo . '</div>';
}

// Job!
$show_job_titles = of_get_option('show_job_titles');
if ( $job = $author_obj->job_title && $show_job_titles ) {
echo '<p class="job-title">' . esc_attr( $author_obj->job_title ) . '</p>';
}
// Description
if ( $author_obj->description ) {
echo '<p>' . esc_attr( $author_obj->description ) . '</p>';
Expand Down
9 changes: 8 additions & 1 deletion partials/author-bio-social-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
* Figure out whether to hide the author's email address
*/
$user_meta = get_user_meta($author_obj->ID);
$show_email = $user_meta['show_email'][0];

$show_email = 'off';
if (isset($user_meta['show_email'][0])) {
$show_email = $user_meta['show_email'][0];
} else if ( !empty($author_obj->show_email) ) {
$show_email = $author_obj->show_email;
}

?>
<ul class="social-links">
<?php if ( $fb = $author_obj->fb ) { ?>
Expand Down

0 comments on commit 69629c2

Please sign in to comment.