function widget($args, $instance)
    {
        global $post;
        extract($args);
        $authors = array();
        $bios = '';
        if (get_post_meta($post->ID, 'largo_byline_text')) {
            $byline_text = esc_attr(get_post_meta($post->ID, 'largo_byline_text', true));
        }
        $is_series_landing = function_exists('largo_is_series_landing') ? largo_is_series_landing($post) : false;
        if ((is_singular() || is_author() || $is_series_landing) && empty($byline_text)) {
            if (is_singular() || $is_series_landing) {
                if (function_exists('get_coauthors')) {
                    $authors = get_coauthors(get_queried_object_id());
                } else {
                    $authors = array(get_user_by('id', get_queried_object()->post_author));
                }
            } else {
                if (is_author()) {
                    $authors = array(get_queried_object());
                }
            }
            // make sure we have at least one bio before we show the widget
            foreach ($authors as $key => $author) {
                $bio = trim($author->description);
                if (!is_author() && empty($bio)) {
                    unset($authors[$key]);
                } else {
                    $bios .= $bio;
                }
            }
            if (!is_author() && empty($bios)) {
                return;
            }
            foreach ($authors as $author_obj) {
                $ctx = array('author_obj' => $author_obj);
                ?>

				<div class="author-box row-fluid author vcard clearfix">
					<?php 
                largo_render_template('partials/author-bio', 'description', $ctx);
                ?>
					<?php 
                largo_render_template('partials/author-bio', 'social-links', $ctx);
                ?>
				</div>

				<?php 
            }
            // foreach
        } elseif (empty($byline_text)) {
            _e('Not a valid author context');
        }
        echo $after_widget;
    }
Example #2
1
 /**
  * Filters {{ post.authors }} to return authors stored from Co-Authors Plus
  * @since 1.1.4
  * @param array $author
  * @param Post $post
  * @return array of User objects
  */
 public function authors($author, $post)
 {
     $authors = array();
     $cauthors = get_coauthors($post->ID);
     foreach ($cauthors as $author) {
         $uid = $this->get_user_uid($author);
         if ($uid) {
             $authors[] = new \Timber\User($uid);
         } else {
             $authors[] = new CoAuthorsPlusUser($author);
         }
     }
     return $authors;
 }
 function action_add_rss_guest_authors()
 {
     $coauthors = get_coauthors();
     // remove the first guest author who is added to the first dc:creator element
     array_shift($coauthors);
     foreach ($coauthors as $coauthor) {
         echo '      <dc:creator><![CDATA[' . $coauthor->display_name . "]]></dc:creator>\n";
     }
 }
Example #4
0
function cap_update_amp_json_metadata($metadata, $post)
{
    $authors = get_coauthors($post->ID);
    $authors_json = array();
    foreach ($authors as $author) {
        $authors_json[] = array('@type' => 'Person', 'name' => $author->display_name);
    }
    $metadata['author'] = $authors_json;
    return $metadata;
}
/**
 * Load Author Boxes
 *
 * @author Bill Erickson
 * @link http://www.billerickson.net/wordpress-post-multiple-authors/
 */
function be_author_box()
{
    if (!is_single()) {
        return;
    }
    if (function_exists('get_coauthors')) {
        $authors = get_coauthors();
        foreach ($authors as $author) {
            be_do_author_box($author->data->ID);
        }
    } else {
        be_do_author_box(get_the_author_ID());
    }
}
 public function wplms_coauthor_plus_course_instructor($authors, $post_id)
 {
     if (function_exists('get_coauthors')) {
         $coauthors = get_coauthors($post_id);
         if (isset($coauthors) && is_array($coauthors)) {
             $authors = array();
             foreach ($coauthors as $author) {
                 if (!in_array($author->ID, $authors)) {
                     $authors[] = $author->ID;
                 }
             }
         }
     }
     return $authors;
 }
Example #7
0
 function CoAuthorsIterator($postID = 0)
 {
     global $post, $authordata, $wpdb;
     $postID = (int) $postID;
     if (!$postID && $post) {
         $postID = (int) $post->ID;
     }
     if (!$postID) {
         trigger_error(__('No post ID provided for CoAuthorsIterator constructor. Are you not in a loop or is $post not set?', 'co-authors-plus'));
     }
     //return null;
     $this->original_authordata = $authordata;
     $this->authordata_array = get_coauthors($postID);
     $this->count = count($this->authordata_array);
 }
 /**
  * Test assigning a Co-Author to a post
  */
 public function test_add_coauthor_to_post()
 {
     global $coauthors_plus;
     $coauthors = get_coauthors($this->author1_post1);
     $this->assertEquals(1, count($coauthors));
     // append = true, should preserve order
     $editor1 = get_user_by('id', $this->editor1);
     $coauthors_plus->add_coauthors($this->author1_post1, array($editor1->user_login), true);
     $coauthors = get_coauthors($this->author1_post1);
     $this->assertEquals(array($this->author1, $this->editor1), wp_list_pluck($coauthors, 'ID'));
     // append = false, overrides existing authors
     $coauthors_plus->add_coauthors($this->author1_post1, array($editor1->user_login), false);
     $coauthors = get_coauthors($this->author1_post1);
     $this->assertEquals(array($this->editor1), wp_list_pluck($coauthors, 'ID'));
 }
/**
 * Retrieve and compile Post Byline Information
 */
function hsinsider_get_post_byline()
{
    $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
    if (get_the_time('U') !== get_the_modified_time('U')) {
        $time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date()));
    } else {
        $time_string = sprintf($time_string, esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date()));
    }
    $posted_on = '<span class="posted_on">' . $time_string . '</span>';
    $byline = hsinsider_get_coauthors() . $posted_on;
    $author = get_coauthors()[0];
    $avatar = '';
    if (!is_author()) {
        $avatar = get_avatar($author->ID, 96, '', '', array('class' => 'img-circle'));
    }
    echo '<figure class="byline">' . wp_kses_post($avatar) . '<figcaption>' . wp_kses_post($byline) . '</figcaption></figure>';
}
 /**
  * Test assigning a WP user a role on a post.
  */
 public function test_manage_author_roles_relationships()
 {
     global $coauthors_plus;
     $author1 = get_user_by('id', $this->author1);
     $editor1 = get_user_by('id', $this->editor1);
     // Setup: assign author1 as the only co-author (byline)
     $coauthors_plus->add_coauthors($this->author1_post1, array($author1->user_nicename), false);
     $this->assertEquals($this->author1, get_post($this->author1_post1)->post_author);
     // Add a coauthor in a non-byline role. Should not be returned by get_coauthors.
     \CoAuthorsPlusRoles\set_author_on_post($this->author1_post1, $editor1, 'contributor');
     $coauthors = get_coauthors($this->author1_post1);
     $coauthors_this_plugin = CoAuthorsPlusRoles\get_coauthors($this->author1_post1);
     $this->assertEquals(count($coauthors), count($coauthors_this_plugin));
     $this->assertEquals(1, count($coauthors));
     $all_credits = CoAuthorsPlusRoles\get_coauthors($this->author1_post1, array('author_role' => 'any'));
     $this->assertEquals(2, count($all_credits));
     // Remove a co-author from a post
     \CoAuthorsPlusRoles\remove_author_from_post($this->author1_post1, $this->editor1);
     $all_credits = CoAuthorsPlusRoles\get_coauthors($this->author1_post1, array('author_role' => 'any'));
     $this->assertEquals(1, count($all_credits));
 }
 /**
  * Filter the authors
  *
  * @param array  $authors  The current authors
  * @param int    $post_id  The current post ID
  */
 function authors($authors, $post_id)
 {
     if (function_exists('get_coauthors')) {
         $coauthors = get_coauthors($post_id);
         $authors = array();
         foreach ($coauthors as $coauthor) {
             $author = new stdClass();
             $author->ID = $coauthor->ID;
             $author->display_name = is_a($coauthor, 'WP_User') ? $coauthor->data->display_name : $coauthor->display_name;
             $author->first_name = $coauthor->first_name;
             $author->last_name = $coauthor->last_name;
             $author->user_login = is_a($coauthor, 'WP_User') ? $coauthor->data->user_login : $coauthor->user_login;
             $author->user_nicename = is_a($coauthor, 'WP_User') ? $coauthor->data->user_nicename : $coauthor->user_nicename;
             $author->user_email = is_a($coauthor, 'WP_User') ? $coauthor->data->user_email : $coauthor->user_email;
             $author->user_url = is_a($coauthor, 'WP_User') ? $coauthor->data->user_url : $coauthor->website;
             $author->bio = $coauthor->description;
             $authors[] = $author;
         }
     }
     return $authors;
 }
/**
* Set replacement values for specific tokens with Post Author Box
*/
function pabx_add_replace_values($tokens)
{
    global $coauthors_plus;
    if (!function_exists('coauthors')) {
        return $tokens;
    }
    $coauthor = array_shift(get_coauthors());
    // Co-Authors Plus specific tokens
    $tokens['%coauthors%'] = coauthors(null, null, null, null, false);
    $tokens['%coauthors_posts_links%'] = coauthors_posts_links(null, null, null, null, false);
    $tokens['%coauthors_firstnames%'] = coauthors_firstnames(null, null, null, null, false);
    // Modify these tokens too, because they might be guest authors
    $tokens['%display_name%'] = $coauthor->display_name;
    $tokens['%first_name%'] = $coauthor->first_name;
    $tokens['%last_name%'] = $coauthor->last_name;
    $tokens['%description%'] = $coauthor->description;
    $tokens['%email%'] = $coauthor->email;
    $tokens['%jabber%'] = $coauthor->jabber;
    $tokens['%aim%'] = $coauthor->aim;
    $tokens['%avatar%'] = get_avatar($coauthor->user_email);
    return $tokens;
}
Example #13
0
 /**
  * Get the post's first author's name
  *
  * @return string The author's name (last name if set, but has fallbacks)
  */
 function get_first_author_name()
 {
     if (function_exists('get_coauthors')) {
         $authors = get_coauthors($this->id);
     } else {
         $authors = [get_userdata($this->id)];
     }
     if (!$authors) {
         return '';
     }
     $author = $authors[0];
     if ($author->last_name) {
         return $author->last_name;
     }
     return $author->display_name;
 }
Example #14
0
        }
        ?>
	<?php 
    } else {
        ?>
		<meta property="og:image" content="<?php 
        bloginfo('template_url');
        ?>
/img/og-image.png" />
	<?php 
    }
    ?>

	<!-- List the post authors -->
	<?php 
    $authors = get_coauthors();
    foreach ($authors as $author) {
        echo "<meta property=\"article:author\" content=\"" . get_author_posts_url($author->ID) . "\">\n";
    }
    ?>

	<!-- Article publish and expiration dates -->
	<meta property="article:published_time" content="<?php 
    echo get_the_time("Y-m-d\\TH:i:sT");
    ?>
">
	<meta property="article:expiration_time" content="<?php 
    echo date('Y-m-d', strtotime(date('Y-m-d', strtotime(get_the_time('Y-m-d'))) . '+4 day'));
    ?>
">
Example #15
0
        ?>
</strong></li>
			<li><?php 
        echo $postcode;
        ?>
</li>			
		</ul>
		<p class=" right alignright last">
			<!-- <a class="small shiny orange round button" title="Map" href="#">Map &raquo;</a> -->
		</p>
		
		<?php 
        $applicants = array();
        $future_tenants = array();
        $managers = array();
        $co_authors = get_coauthors($post->ID);
        foreach ($co_authors as $author) {
            $user = new WP_User($author->ID);
            // print_r($author);
            if (!empty($user->roles) && is_array($user->roles)) {
                foreach ($user->roles as $role) {
                    // echo $role;
                    if ($role == "applicant") {
                        $applicants[] = $user;
                    } elseif ($role == "future_tenant") {
                        $future_tenants[] = $user;
                    } elseif ($role == "manager") {
                        $managers[] = $user;
                    } elseif ($role == "tenant") {
                        $tenants[] = $user;
                    }
Example #16
0
 //Anzahl Ergebnisse
 echo $wp_query->found_posts . ' Artikel';
 echo '</p>';
 //Zeitraum berechnen
 $parameters = $wp_query->query_vars;
 $parameters['nopaging'] = true;
 $myquery = new WP_Query($parameters);
 $posts = $myquery->posts;
 if (sizeof($posts) > 1) {
     echo '<p class="smalltext">';
     echo 'Zeitraum: ' . get_the_time('j. F Y', $posts[sizeof($posts) - 1]->ID) . ' – ' . get_the_time('j. F Y', $posts[0]->ID);
     echo '</p>';
 }
 //Autoren (sollte noch gegen deaktivierung des Coauthors Plugins abgesichert werden)
 foreach ($posts as $p) {
     $tmp = get_coauthors($p->ID);
     foreach ($tmp as $t) {
         //eventuell könnte man statt einem Link zum Autorenarchiv irgendwie eine Filterfunktion für das aktuelle Archiv implementieren. Aber das ist irgendwie kompliziert.
         $authors[] = '<a href="' . get_author_posts_url($t->ID) . '">' . $t->display_name . '</a>';
     }
 }
 $authors = array_unique($authors);
 asort($authors);
 if (count($authors) > 0) {
     echo '<p class="smalltext">' . (count($authors) > 1 ? count($authors) . ' Autoren' : '1 Autor') . ':';
     echo '<ul class="sidebar_list_categories smalltext">';
     foreach ($authors as $a) {
         echo '<li>' . $a . '</li>';
     }
     echo '</li></p>';
 }
function bdn_xmlrpc_get_posts($args)
{
    global $wp_xmlrpc_server;
    $wp_xmlrpc_server->escape($args);
    $blog_ID = (int) $args[0];
    $username = $args[1];
    $password = $args[2];
    $post_type = $args[3];
    $category = $args[4];
    $numberposts = $args[5];
    $extra = $args[6];
    if (!($user = $wp_xmlrpc_server->login($username, $password))) {
        return $wp_xmlrpc_server->error;
    }
    $category_int = (int) $category;
    if (!empty($category_int)) {
        $category_call = 'cat';
    } else {
        $category_call = 'category_name';
    }
    $post_args = array('numberposts' => $numberposts, 'posts_per_page' => $numberposts, $category_call => $category, 'post_type' => $post_type, 'post_status' => 'any');
    if (is_array($extra)) {
        $post_args = array_merge($post_args, $extra);
    }
    $posts_list = query_posts($post_args);
    if (!$posts_list) {
        $wp_xmlrpc_server->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.'));
        return $wp_xmlrpc_server->error;
    }
    foreach ($posts_list as $entry) {
        if (!current_user_can('edit_post', $entry->ID)) {
            continue;
        }
        $post_date = mysql2date('Ymd\\TH:i:s', $entry->post_date, false);
        $post_date_gmt = mysql2date('Ymd\\TH:i:s', $entry->post_date_gmt, false);
        $post_modified = mysql2date('Ymd\\TH:i:s', $entry->post_modified, false);
        // For drafts use the GMT version of the date
        if ($entry->post_status == 'draft') {
            $post_date_gmt = get_gmt_from_date(mysql2date('Y-m-d H:i:s', $entry->post_date), 'Ymd\\TH:i:s');
        }
        $categories = array();
        $cats = get_the_category($entry->ID, 'category');
        foreach ($cats as $cat) {
            $categories[] = array('name' => $cat->cat_name, 'parent' => $cat->category_parent);
        }
        $publications = array();
        $pubs = get_the_terms($entry->ID, 'publication');
        foreach ($pubs as $pub) {
            $publications[] = $pub->name;
        }
        $post = get_extended($entry->post_content);
        $link = post_permalink($entry->ID);
        // Get the post author info.
        $authors = (array) get_userdata($entry->post_author);
        if (function_exists('get_coauthors')) {
            $authors = get_coauthors($entry->ID);
        }
        $allow_comments = 'open' == $entry->comment_status ? 1 : 0;
        $allow_pings = 'open' == $entry->ping_status ? 1 : 0;
        // Consider future posts as published
        if ($entry->post_status === 'future') {
            $entry->post_status = 'publish';
        }
        $entryPost = array('post_date' => new IXR_Date($post_date), 'post_updated' => new IXR_Date($post_modified), 'userid' => $entry->post_author, 'post_id' => $entry->ID, 'description' => $post['main'], 'post_title' => $entry->post_title, 'link' => $link, 'permaLink' => $link, 'post_parent' => strval($post['post_parent']), 'post_content' => $entry->post_content, 'categories' => $categories, 'mt_excerpt' => $entry->post_excerpt, 'mt_text_more' => $post['extended'], 'mt_allow_comments' => $allow_comments, 'mt_allow_pings' => $allow_pings, 'wp_slug' => $entry->post_name, 'wp_password' => $entry->post_password, 'wp_authors' => $authors, 'date_created_gmt' => new IXR_Date($post_date_gmt), 'post_status' => $entry->post_status, 'custom_fields' => $wp_xmlrpc_server->get_custom_fields($entry->ID), 'publications' => $publications);
        $post_type_taxonomies = get_object_taxonomies(POST_TYPE, 'names');
        $terms = wp_get_object_terms($entry->ID, $post_type_taxonomies);
        $entryPost['terms'] = array();
        foreach ($terms as $term) {
            $entryPost['terms'][] = _prepare_term($term);
        }
        $struct[] = $entryPost;
    }
    $recent_posts = array();
    for ($j = 0; $j < count($struct); $j++) {
        array_push($recent_posts, $struct[$j]);
    }
    return $recent_posts;
}
Example #18
0
/**
 * 
 * Do the mapping from WP post to the array that we're going to build the NPRML from.  
 * This is also where we will do custom mapping if need be.
 * If a mapped custom field does not exist in a certain post, just send the default field.
 * @param  $post
 */
function post_to_nprml_story($post)
{
    $story = array();
    $story[] = array('tag' => 'link', 'attr' => array('type' => 'html'), 'text' => get_permalink($post));
    $use_custom = get_option('dp_npr_push_use_custom_map');
    //get the list of metas available for this post
    $post_metas = get_post_custom_keys($post->ID);
    $teaser_text = '';
    if (!empty($post->post_excerpt)) {
        $teaser_text = $post->post_excerpt;
    }
    $custom_content_meta = get_option('ds_npr_api_mapping_body');
    if ($use_custom && !empty($custom_content_meta) && $custom_content_meta != '#NONE#' && in_array($custom_content_meta, $post_metas)) {
        $content = get_post_meta($post->ID, $custom_content_meta, true);
        $post_for_teaser = $post;
        $post_for_teaser->post_content = $content;
        if (empty($teaser_text)) {
            $teaser_text = nai_get_excerpt($post_for_teaser);
        }
    } else {
        $content = $post->post_content;
        if (empty($teaser_text)) {
            $teaser_text = nai_get_excerpt($post);
        }
    }
    //lets see if there are any plugins that need to fix their shortcodes before we run do_shortcode
    if (has_filter('npr_ds_shortcode_filter')) {
        $content = apply_filters('npr_ds_shortcode_filter', $content);
    }
    //let any plugin that has short codes try and replace those with HTML
    $content = do_shortcode($content);
    //for any remaining short codes, nuke 'em
    $content = strip_shortcodes($content);
    $content = apply_filters('the_content', $content);
    $story[] = array('tag' => 'teaser', 'text' => $teaser_text);
    $custom_title_meta = get_option('ds_npr_api_mapping_title');
    if ($use_custom && !empty($custom_title_meta) && $custom_title_meta != '#NONE#' && in_array($custom_content_meta, $post_metas)) {
        $custom_title = get_post_meta($post->ID, $custom_title_meta, true);
        $story[] = array('tag' => 'title', 'text' => $custom_title);
    } else {
        $story[] = array('tag' => 'title', 'text' => $post->post_title);
    }
    /**
     * 
     *If there is a custom byline configured, send that.
     *If the site is using the coauthurs plugin, and get_coauthors exists, send the display names
     *
     *If no cool things are going on, just send the display name for the post_author field.
     *
     */
    $byline = FALSE;
    $custom_byline_meta = get_option('ds_npr_api_mapping_byline');
    if ($use_custom && !empty($custom_byline_meta) && $custom_byline_meta != '#NONE#' && in_array($custom_content_meta, $post_metas)) {
        $byline = TRUE;
        $story[] = array('tag' => 'byline', 'children' => array(array('tag' => 'name', 'text' => get_post_meta($post->ID, $custom_byline_meta, true))));
    }
    if (function_exists('get_coauthors')) {
        $coauthors = get_coauthors($post->ID);
        if (!empty($coauthors)) {
            $byline = TRUE;
            foreach ($coauthors as $i => $co) {
                $story[] = array('tag' => 'byline', 'children' => array(array('tag' => 'name', 'text' => $co->display_name)));
            }
        } else {
            error_log('we do not have co authors');
        }
    } else {
        error_log('can not find get_coauthors');
    }
    if (!$byline) {
        $story[] = array('tag' => 'byline', 'children' => array(array('tag' => 'name', 'text' => get_the_author_meta('display_name', $post->post_author))));
    }
    // NPR One
    if (!empty($_POST['send_to_nprone'])) {
        $story[] = array('tag' => 'parent', 'attr' => array('id' => '319418027', 'type' => 'collection'));
    }
    #'miniTeaser' => array( 'text' => '' ),
    #'slug' => array( 'text' => '' ),
    $story[] = array('tag' => 'storyDate', 'text' => mysql2date('D, d M Y H:i:s +0000', $post->post_date_gmt));
    $story[] = array('tag' => 'pubDate', 'text' => mysql2date('D, d M Y H:i:s +0000', $post->post_modified_gmt));
    $story[] = array('tag' => 'lastModifiedDate', 'text' => mysql2date('D, d M Y H:i:s +0000', $post->post_modified_gmt));
    $story[] = array('tag' => 'partnerId', 'text' => $post->guid);
    //TODO:  When the API accepts sending both text and textWithHTML, send a totally bare text.  Don't do do_shortcode().
    //for now (using the npr story api) we can either send text or textWithHTML, not both.
    //it would be nice to send text after we strip all html and shortcodes, but we need the html
    //and sending both will duplicate the data in the API
    $story[] = array('tag' => 'textWithHtml', 'children' => split_paragraphs($content));
    $perms_group = get_option('ds_npr_story_default_permission');
    if (!empty($perms_group)) {
        $story[] = array('tag' => 'permissions', 'children' => array(array('tag' => 'permGroup', 'attr' => array('id' => $perms_group))));
    }
    $custom_media_credit = get_option('ds_npr_api_mapping_media_credit');
    $custom_media_agency = get_option('ds_npr_api_mapping_media_agency');
    /* remove this for now until we decide if we're going to actually do this...km
       $dist_media_option = get_option('ds_npr_api_mapping_distribute_media');
       $dist_media_polarity = get_option('ds_npr_api_mapping_distribute_media_polarity');
       */
    $args = array('order' => 'DESC', 'post_mime_type' => 'image', 'post_parent' => $post->ID, 'post_status' => null, 'post_type' => 'attachment');
    $images = get_children($args);
    $primary_image = get_post_thumbnail_id($post->ID);
    foreach ($images as $image) {
        $custom_credit = '';
        $custom_agency = '';
        $image_metas = get_post_custom_keys($image->ID);
        if ($use_custom && !empty($custom_media_credit) && $custom_media_credit != '#NONE#' && in_array($custom_media_credit, $image_metas)) {
            $custom_credit = get_post_meta($image->ID, $custom_media_credit, true);
        }
        if ($use_custom && !empty($custom_media_agency) && $custom_media_agency != '#NONE#' && in_array($custom_media_agency, $image_metas)) {
            $custom_agency = get_post_meta($image->ID, $custom_media_agency, true);
        }
        if ($use_custom && !empty($dist_media_option) && $dist_media_option != '#NONE#' && in_array($dist_media_option, $image_metas)) {
            $dist_media = get_post_meta($image->ID, $dist_media_option, true);
        }
        //if the image field for distribute is set and polarity then send it.
        //all kinds of other math when polarity is negative or the field isn't set.
        $image_type = 'standard';
        if ($image->ID == $primary_image) {
            $image_type = 'primary';
        }
        //is the image in the content?  If so, tell the APi with a flag that CorePublisher knows
        //WP may add something like "-150X150" to the end of the filename, before the extension.  Isn't that nice?
        $image_name_parts = split(".", $image_guid);
        $image_regex = "/" . $image_name_parts[0] . "\\-[a-zA-Z0-9]*" . $image_name_parts[1] . "/";
        $in_body = "";
        if (preg_match($image_regex, $content)) {
            if (strstr($image->guid, '?')) {
                $in_body = "&origin=body";
            } else {
                $in_body = "?origin=body";
            }
        }
        $story[] = array('tag' => 'image', 'attr' => array('src' => $image->guid . $in_body, 'type' => $image_type), 'children' => array(array('tag' => 'title', 'text' => $image->post_title), array('tag' => 'caption', 'text' => $image->post_excerpt), array('tag' => 'producer', 'text' => $custom_credit), array('tag' => 'provider', 'text' => $custom_agency)));
    }
    //should be able to do the same as image for audio, with post_mime_typ = 'audio' or something.
    $args = array('order' => 'DESC', 'post_mime_type' => 'audio', 'post_parent' => $post->ID, 'post_status' => null, 'post_type' => 'attachment');
    $audios = get_children($args);
    foreach ($audios as $audio) {
        $audio_meta = wp_get_attachment_metadata($audio->ID);
        $caption = $audio->post_excerpt;
        //if we don't have excerpt filled in, try content
        if (empty($caption)) {
            $caption = $audio->post_content;
        }
        $story[] = array('tag' => 'audio', 'children' => array(array('tag' => 'format', 'children' => array(array('tag' => 'mp3', 'text' => $audio->guid))), array('tag' => 'description', 'text' => $caption), array('tag' => 'duration', 'text' => $audio_meta['length'])));
    }
    if ($enclosures = get_metadata('post', $post->ID, 'enclosure')) {
        // This logic is specifically driven by enclosure metadata items that are
        // created by the PowerPress podcasting plug-in. It will likely have to be
        // re-worked if we need to accomodate other plug-ins that use enclosures.
        foreach ($enclosures as $enclosure) {
            $pieces = explode("\n", $enclosure);
            if (!empty($pieces[3])) {
                $metadata = unserialize($pieces[3]);
                $duration = !empty($metadata['duration']) ? nprapi_convert_duration($metadata['duration']) : NULL;
            }
            $story[] = array('tag' => 'audio', 'children' => array(array('tag' => 'duration', 'text' => !empty($duration) ? $duration : 0), array('tag' => 'format', 'children' => array(array('tag' => 'mp3', 'text' => $pieces[0])))));
        }
    }
    return $story;
}
function display_testimonies($arguments = array())
{
    $post_id = $arguments['post_id'] ? $arguments['post_id'] : get_the_ID();
    $number_requested = $arguments['number_requested'] ? $arguments['number_requested'] : 3;
    $section_title = $arguments['section_title'] ? $arguments['section_title'] : 'Testimonies';
    $query_args = array('orderby' => 'rand', 'post_type' => 'testimonies', 'programs_tax' => get_the_slug($post_id), 'posts_per_page' => $number_requested);
    $the_query = new WP_Query($query_args);
    // The Loop
    if ($the_query->have_posts()) {
        ?>
    <div class="standard-testimonies-container">
        <h2><?php 
        echo $section_title;
        ?>
</h2>
    
        <?php 
        while ($the_query->have_posts()) {
            $the_query->the_post();
            // Get Author Information
            $author = get_coauthors($post->ID)[0];
            ?>
            <div class="testimony-container">
                <div class="row">
                    <div class="columns medium-10">
                        <h6><i class="fa fa-quote-left"></i><?php 
            the_title();
            ?>
</h6>
                        <?php 
            the_content();
            ?>
                        <div class="testimony-author-info">- <?php 
            echo $author->display_name . ', ' . rwmb_meta('author_involvement');
            ?>
</div>
                    </div>
                    <div class="columns medium-2 author-image">
                        <?php 
            echo get_the_post_thumbnail($author->ID, 'thumbnail', array('class' => 'img-responsive-80'));
            ?>
                    </div>
                </div>
            </div>
        
        <?php 
        }
        ?>
    </div>
        
    <?php 
    }
    /* Restore original Post Data */
    wp_reset_postdata();
    ?>

    


    
    
<?php 
}
 /**
  * Filter non-native users added by Co-Author-Plus in Jetpack
  *
  * @since 3.1
  *
  * @param array $og_tags Required. Array of Open Graph Tags.
  * @param array $image_dimensions Required. Dimensions for images used.
  * @return array Open Graph Tags either as they were passed or updated.
  */
 public function filter_jetpack_open_graph_tags($og_tags, $image_dimensions)
 {
     if (is_author()) {
         $author = get_queried_object();
         $og_tags['og:title'] = $author->display_name;
         $og_tags['og:url'] = get_author_posts_url($author->ID, $author->user_nicename);
         $og_tags['og:description'] = $author->description;
         $og_tags['profile:first_name'] = $author->first_name;
         $og_tags['profile:last_name'] = $author->last_name;
         if (isset($og_tags['article:author'])) {
             $og_tags['article:author'] = get_author_posts_url($author->ID, $author->user_nicename);
         }
     } else {
         if (is_singular() && $this->is_post_type_enabled()) {
             $authors = get_coauthors();
             if (!empty($authors)) {
                 $author = array_shift($authors);
                 if (isset($og_tags['article:author'])) {
                     $og_tags['article:author'] = get_author_posts_url($author->ID, $author->user_nicename);
                 }
             }
         }
     }
     // Send back the updated Open Graph Tags
     return apply_filters('coauthors_open_graph_tags', $og_tags);
 }
 private function get_bio()
 {
     // No Bio for Off-The-Hills
     if ($this->get_article_meta('off-the-hill-author')) {
         return false;
     }
     // Use Coauthors Plugin, Combining Bios if Necessary
     if (function_exists('get_coauthors')) {
         // Built an Array of User Bios
         $bios = array();
         foreach (get_coauthors($this->post->ID) as $author_data) {
             $bios[] = $author_data->description;
         }
         // Convert Bios to Unified String, with Separator Space
         return implode(' ', $bios);
         // Use Standard WP Functions
     } else {
         $author_data = get_userdata($this->post->post_author);
         $bio = $author_data->description;
         if (!$bio) {
             return "This author does not have a bio set on WordPress.";
         }
         return $bio;
     }
 }
 /**
  * Swap one Co Author with another on all posts for which they are an author. Unlike rename-coauthor,
  * this leaves the original Co Author term intact and works when the 'to' user already has a co-author term.
  *
  * @subcommand swap-coauthors
  * @synopsis --from=<user-login> --to=<user-login> [--post_type=<ptype>] [--dry=<dry>]
  */
 public function swap_coauthors($args, $assoc_args)
 {
     global $coauthors_plus, $wpdb;
     $defaults = array('from' => null, 'to' => null, 'post_type' => 'post', 'dry' => false);
     $assoc_args = array_merge($defaults, $assoc_args);
     $dry = $assoc_args['dry'];
     $from_userlogin = $assoc_args['from'];
     $to_userlogin = $assoc_args['to'];
     $from_userlogin_prefixed = 'cap-' . $from_userlogin;
     $to_userlogin_prefixed = 'cap-' . $to_userlogin;
     $orig_coauthor = $coauthors_plus->get_coauthor_by('user_login', $from_userlogin);
     if (!$orig_coauthor) {
         WP_CLI::error("No co-author found for {$from_userlogin}");
     }
     if (!$to_userlogin) {
         WP_CLI::error('--to param must not be empty');
     }
     $to_coauthor = $coauthors_plus->get_coauthor_by('user_login', $to_userlogin);
     if (!$to_coauthor) {
         WP_CLI::error("No co-author found for {$to_userlogin}");
     }
     WP_CLI::line("Swapping authorship from {$from_userlogin} to {$to_userlogin}");
     $query_args = array('post_type' => $assoc_args['post_type'], 'order' => 'ASC', 'orderby' => 'ID', 'posts_per_page' => 100, 'paged' => 1, 'tax_query' => array(array('taxonomy' => $coauthors_plus->coauthor_taxonomy, 'field' => 'slug', 'terms' => array($from_userlogin_prefixed))));
     $posts = new WP_Query($query_args);
     $posts_total = 0;
     WP_CLI::line("Found {$posts->found_posts} posts to update.");
     while ($posts->post_count) {
         foreach ($posts->posts as $post) {
             $coauthors = get_coauthors($post->ID);
             if (!is_array($coauthors) || !count($coauthors)) {
                 continue;
             }
             $coauthors = wp_list_pluck($coauthors, 'user_login');
             $posts_total++;
             if (!$dry) {
                 // Remove the $from_userlogin from $coauthors
                 foreach ($coauthors as $index => $user_login) {
                     if ($from_userlogin === $user_login) {
                         unset($coauthors[$index]);
                         break;
                     }
                 }
                 // Add the 'to' author on
                 $coauthors[] = $to_userlogin;
                 // By not passing $append = false as the 3rd param, we replace all existing coauthors
                 $coauthors_plus->add_coauthors($post->ID, $coauthors, false);
                 WP_CLI::line($posts_total . ': Post #' . $post->ID . ' has been assigned "' . $to_userlogin . '" as a co-author');
                 clean_post_cache($post->ID);
             } else {
                 WP_CLI::line($posts_total . ': Post #' . $post->ID . ' will be assigned "' . $to_userlogin . '" as a co-author');
             }
         }
         // In dry mode, we must manually advance the page
         if ($dry) {
             $query_args['paged']++;
         }
         $this->stop_the_insanity();
         $posts = new WP_Query($query_args);
     }
     WP_CLI::success('All done!');
 }
 /**
  * Hook into Jetpack Sharing's Twitter related accounts filter to add all authors as 'related' accounts
  * when shared to Twitter.
  *
  * Once a post is shared to Twitter, Twitter presents the user with a list of Related/Recommended accounts - this filter
  * gives us the ability to tell Twitter exactly which accounts to suggest - in this case, the post's Authors
  * 
  * @param  array $related Array of related Twitter usernames
  * @param  int $post_id The id of the post being shared
  * @return array The array of Twitter usernames to suggest as related / recommended
  */
 public function filter_jetpack_sharing_twitter_related($related, $post_id)
 {
     if (!function_exists('get_coauthors')) {
         return $via;
     }
     $coauthors = get_coauthors($post_id);
     if (!is_array($coauthors) || empty($coauthors)) {
         return $related;
     }
     foreach ($coauthors as $coauthor) {
         if (!isset($coauthor->twitter) || empty($coauthor->twitter) || !(int) $coauthor->enable_twitter_related) {
             continue;
         }
         $related[$coauthor->twitter] = $coauthor->description;
     }
     return $related;
 }
 /**
  * Filter Edit Flow's 'ef_story_budget_term_column_value' to add co-authors to the story budget
  *
  * @see https://github.com/danielbachhuber/Co-Authors-Plus/issues/2
  */
 function filter_ef_story_budget_term_column_value($column_name, $post, $parent_term)
 {
     // We only want to modify the 'author' column
     if ('author' != $column_name) {
         return $column_name;
     }
     $co_authors = get_coauthors($post->ID);
     $co_authors_names = '';
     foreach ($co_authors as $co_author) {
         $co_authors_names .= $co_author->display_name . ', ';
     }
     return rtrim($co_authors_names, ', ');
 }
Example #25
0
function post_notification_create_email($id, $template = '')
{
    $blogname = get_option('blogname');
    if (get_option('post_notification_hdr_nl') == 'rn') {
        $hdr_nl = "\r\n";
    } else {
        $hdr_nl = "\n";
    }
    if ($template == '') {
        $template = get_option('post_notification_template');
    }
    if (substr($template, -5) == '.html') {
        $html_email = true;
    } else {
        $html_email = false;
    }
    //Get the post
    $post = get_post($id);
    $post_url = get_permalink($post->ID);
    $post_author = get_userdata($post->post_author);
    $post_author = $post_author->display_name;
    //cz
    $co_authors = get_coauthors($post->ID);
    $post_author = '';
    //$post_author = coauthors_posts_links();
    //$post_author = count($co_authors);
    foreach ($co_authors as $key => $co_author) {
        $post_author .= $co_author->display_name . ' ';
        if ($key + 1 < count($co_authors)) {
            $post_author .= '& ';
        }
    }
    $post_title = $post->post_title;
    if (get_option('post_notification_show_content') == 'yes') {
        $post_content = stripslashes($post->post_content);
    } else {
        if (get_option('post_notification_show_content') == 'more') {
            $post_content = stripslashes($post->post_content);
            list($post_content, $more_content) = split('<!--more', $post_content);
            if ($more_content) {
                $post_content .= '<a href="@@permalink" >' . get_option('post_notification_read_more') . '</a>';
            }
        } else {
            if (get_option('post_notification_show_content') == 'excerpt') {
                if (strlen($post->post_excerpt)) {
                    $post_content = stripslashes($post->post_excerpt);
                } else {
                    $words = explode(' ', stripslashes($post->post_content));
                    $tag = false;
                    $wcount = 0;
                    foreach ($words as $word) {
                        $stag = strrpos($word, '<');
                        $etag = strrpos($word, '>');
                        if (!is_bool($stag) || !is_bool($etag)) {
                            if (is_bool($stag)) {
                                $tag = false;
                            } else {
                                if (is_bool($etag)) {
                                    $tag = true;
                                } else {
                                    if ($stag < $etag) {
                                        $tag = false;
                                    } else {
                                        $tag = true;
                                    }
                                }
                            }
                        }
                        if (!$tag) {
                            $wcount++;
                        }
                        if ($wcount > 55) {
                            break;
                        }
                        $post_content .= $word . " ";
                    }
                    $post_content = balanceTags($post_content, true);
                }
                $post_content .= '<br /><a href="@@permalink" >' . get_option('post_notification_read_more') . '</a>';
            }
        }
    }
    // Run filters over the post
    if ($post_content) {
        //backup
        $filter_backup = $GLOBALS['wp_filter'];
        //Remove unwanted Filters
        $rem_filters = get_option('post_notification_the_content_exclude');
        if (is_string($rem_filters) && strlen($rem_filters)) {
            $rem_filters = unserialize($rem_filters);
        }
        if (!is_array($rem_filters)) {
            $rem_filters = array();
        }
        foreach ($rem_filters as $rem_filter) {
            remove_filter('the_content', $rem_filter);
        }
        if (!$html_email) {
            remove_filter('the_content', 'convert_smilies');
            //We defenetly don't want smilie - Imgs in Text-Mails.
        }
        $post_content = apply_filters('the_content', $post_content);
        //recover for other plugins
        $GLOBALS['wp_filter'] = $filter_backup;
    }
    // Do some date stuff
    $post_date = mysql2date(get_settings('date_format'), $post->post_date);
    $post_time = mysql2date(get_settings('time_format'), $post->post_date);
    if (!$html_email) {
        if (get_option('post_notification_debug') == 'yes') {
            echo 'Date1: ' . htmlspecialchars($post_date) . '<br />';
        }
        if (function_exists('iconv') && strpos(phpversion(), '4') == 0) {
            //html_entity_decode does not support UTF-8 in php < 5
            $post_time = ($temp = iconv(get_settings('blog_charset'), 'ISO8859-1', $post_time)) != "" ? $temp : $post_time;
            $post_date = ($temp = iconv(get_settings('blog_charset'), 'ISO8859-1', $post_date)) != "" ? $temp : $post_date;
        }
        if (get_option('post_notification_debug') == 'yes') {
            echo 'Date2: ' . htmlspecialchars($post_date) . '<br />';
        }
        $post_time = @html_entity_decode($post_time, ENT_QUOTES, get_settings('blog_charset'));
        $post_date = @html_entity_decode($post_date, ENT_QUOTES, get_settings('blog_charset'));
        if (get_option('post_notification_debug') == 'yes') {
            echo 'Date3: ' . htmlspecialchars($post_date) . '<br />';
        }
        if (function_exists('iconv') && strpos(phpversion(), '4') == 0) {
            //html_entity_decode does not support UTF-8 in php < 5
            $post_time = ($temp = iconv('ISO8859-1', get_settings('blog_charset'), $post_time)) != "" ? $temp : $post_time;
            $post_date = ($temp = iconv('ISO8859-1', get_settings('blog_charset'), $post_date)) != "" ? $temp : $post_date;
        }
        if (get_option('post_notification_debug') == 'yes') {
            echo 'Date4: ' . htmlspecialchars($post_date) . '<br />';
        }
    }
    $post_title = strip_tags($post_title);
    //Convert from HTML to text.
    if (!$html_email && isset($post_content)) {
        require_once POST_NOTIFICATION_PATH . 'class.html2text.php';
        $h2t =& new html2text($post_content);
        $post_content = $h2t->get_text();
    }
    // Load template
    $body = post_notification_ldfile($template);
    if (get_option('post_notification_debug') == 'yes') {
        echo "Email variables: <br /><table>";
        echo '<tr><td>Emailtype</td><td>' . ($html_email ? 'HTML' : 'TEXT') . '</td>';
        echo '<tr><td>@@title</td><td>' . $post_title . '</td></tr>';
        echo '<tr><td>@@permalink</td><td>' . $post_url . '</td></tr>';
        echo '<tr><td>@@author</td><td>' . $post_author . '</td></tr>';
        echo '<tr><td>@@time</td><td>' . $post_time . '</td></tr>';
        echo '<tr><td>@@date</td><td>' . $post_date . '</td></tr>';
        echo "</table>";
    }
    // Replace variables
    $body = str_replace('@@content', $post_content, $body);
    //Insert the posting first. -> for Replacements
    $body = str_replace('@@title', $post_title, $body);
    $body = str_replace('@@permalink', $post_url, $body);
    $body = str_replace('@@author', $post_author, $body);
    $body = str_replace('@@time', $post_time, $body);
    $body = str_replace('@@date', $post_date, $body);
    //cb fix
    $body = str_replace('<img class="alignright', '<img align="right" class="alignright', $body);
    $body = str_replace('<img class="alignleft', '<img align="left" hspace="5" vspace="5" class="alignleft', $body);
    // User replacements
    if (function_exists('post_notificataion_uf_perPost')) {
        $body = post_notification_arrayreplace($body, post_notificataion_uf_perPost($id));
    }
    // EMAIL HEADER
    $header = post_notification_header($html_email);
    // SUBJECT
    $subject = get_option('post_notification_subject');
    $subject = str_replace('@@blogname', $blogname, $subject);
    if ($post_title != '') {
        $subject = str_replace('@@title', $post_title, $subject);
    } else {
        $subject = str_replace('@@title', __('New post', 'post_notification'), $subject);
    }
    $subject = post_notification_encode($subject, get_settings('blog_charset'));
    //cz fix dup spaces in subject:
    $subject = str_replace('  ', ' ', $subject);
    //cb fix
    $subject = htmlspecialchars_decode($subject, ENT_QUOTES);
    $header = htmlspecialchars_decode($header, ENT_QUOTES);
    $rv = array();
    $rv['id'] = $id;
    $rv['subject'] = $subject;
    $rv['body'] = $body;
    $rv['header'] = $header;
    return $rv;
}
 /**
  * Creates a post on Medium.
  */
 public static function cross_post($post, $medium_post, $medium_user)
 {
     $tag_data = wp_get_post_terms($post->ID, array("post_tag", "slug"));
     $tags = array();
     $slugs = array();
     foreach ($tag_data as $tag) {
         if ($tag->taxonomy == "post_tag") {
             $tags[] = $tag->name;
         } elseif ($tag->taxonomy == "slug") {
             // For installations that have the custom taxonomy "slug", ensure that
             // these are are the head of the tag list.
             $slugs[] = $tag->name;
         }
     }
     $tags = array_values(array_unique(array_merge($slugs, $tags)));
     if (class_exists('CoAuthors_Guest_Authors')) {
         // Handle guest-authors if the CoAuthors Plus plugin is installed.
         $coauthors = get_coauthors($post->ID);
         $primary_author = $coauthors[0];
         if ($primary_author->type == "guest-author") {
             $medium_post->byline_name = $primary_author->display_name;
             $medium_post->byline_email = $primary_author->user_email;
         }
     }
     $permalink = get_permalink($post->ID);
     $content = Medium_View::render("content-rendered-post", array("title" => $post->post_title, "content" => self::_prepare_content($post), "cross_link" => $medium_post->cross_link == "yes", "site_name" => get_bloginfo('name'), "permalink" => $permalink, "byline" => $medium_post->byline_name), true);
     $body = array("title" => $post->post_title, "content" => $content, "tags" => $tags, "contentFormat" => "html", "canonicalUrl" => $permalink, "license" => $medium_post->license, "publishStatus" => $medium_post->status, "publishedAt" => mysql2date('c', $post->post_date), "notifyFollowers" => $medium_post->follower_notification == "yes");
     $data = json_encode($body);
     if ($medium_post->publication_id != NO_PUBLICATION) {
         $path = "/v1/publications/{$medium_post->publication_id}/posts";
     } else {
         $path = "/v1/users/{$medium_user->id}/posts";
     }
     try {
         $created_medium_post = self::_medium_request("POST", $path, $medium_user->token, $data, array("Content-Type" => "application/json"));
     } catch (Exception $e) {
         // Retry once if we got a timeout
         if ($e->getCode() == -2) {
             error_log("RETRYING POST {$post->ID} '{$post->post_title}' due to timeout, delaying...");
             sleep(5);
             $created_medium_post = self::_medium_request("POST", $path, $medium_user->token, $data, array("Content-Type" => "application/json"));
         } else {
             throw $e;
         }
     }
     $medium_post->id = $created_medium_post->id;
     // Don't derail the migration just because of a claims failure
     try {
         if ($medium_post->byline_email) {
             // Create a claim for the post, if necessary.
             self::create_post_claim($medium_post, $medium_user, $medium_post->byline_email);
         }
     } catch (Exception $e) {
         error_log("ERROR: Claim call failed {$e->getMessage}(), {$e->getCode}()");
     }
     return $created_medium_post;
 }
    /**
     * Generate the html for a single draggable item
     * @param int $post_id
     * @param boolean $use_image_checked if true, render this item with the "use image" checkbox checked (if enabled)
     * @return string containing the li element.
     */
    protected function draggable_item_html($post_id, $use_image_checked = false)
    {
        $post = get_post($post_id);
        $bylines = array();
        if (is_plugin_active('co-authors-plus/co-authors-plus.php')) {
            $authors = get_coauthors($post_id);
            foreach ($authors as $author) {
                $bylines[] = $author->display_name;
            }
            if (empty($bylines)) {
                $authorstr = esc_html__('(no authors)', 'fieldmanager');
            } else {
                $authorstr = implode(', ', $bylines);
            }
        } else {
            $author = get_userdata($post->post_author);
            $authorstr = $author->display_name;
        }
        $image_meta = get_post_meta($post_id, '_thumbnail_id');
        $permalink = get_permalink($post_id);
        if (isset($image_meta[0])) {
            $image = wp_get_attachment_image($image_meta[0], array(32, 32));
        } else {
            $image = '';
        }
        $li = sprintf('<li class="draggable-post" id="draggable-post-%d" post_id="%d">', $post_id, $post_id);
        $li_inner = sprintf('<strong><a href="%s" target="_new">%s</a></strong><br />
							<small>%s &mdash; %s</small><br />
							<small><em>%s %s</em></small>', $permalink, $post->post_title, $post->post_date, $authorstr, $image, $post->post_excerpt);
        if ($this->use_image_checkbox && $image) {
            $checked = $use_image_checked ? 'checked' : '';
            $li_inner .= sprintf('<small><input type="checkbox" value="1" name="%s[_image_flags][%d]" %s /> Use image?</small>', $this->get_form_name(), $post_id, $checked);
        }
        $li = $li . apply_filters('fieldmanager_draggablepost_li_content', $li_inner, $post_id) . '</li>';
        return $li;
    }
    the_content();
    ?>
        <?php 
}
?>
    </div>
    
    
    <ul id="og-grid" class="og-grid">
        
        <?php 
// Retrieve All Guest Authors
$guest_authors = get_posts('post_type=guest-author&numberposts=-1');
foreach ($guest_authors as $guest_author) {
    // Build Co-Author Object
    $coauthor_object = get_coauthors($guest_author->ID);
    // Build Variables for Author Profile
    $display_name = $guest_author->post_title;
    $author_bio = $coauthor_object[0]->description;
    $full_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($guest_author->ID), 'full')[0];
    $thumb_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($guest_author->ID), 'medium')[0];
    echo "<li><a href='#_' data-largesrc='{$full_image_url}' data-title='{$display_name}' data-description='{$author_bio}'><img src='{$thumb_image_url}' /></a></li>";
}
?>
    </ul>
        
    <script src="<?php 
echo get_bloginfo('template_directory');
?>
/js/our-people-grid.js"></script>
    <script>
Example #29
0
        the_category_ID();
        ?>
" class="cat_link"><?php 
        $category = get_the_category();
        echo $category[0]->cat_name;
        ?>
</a>
				<div class="title_content">
					<h4><?php 
        the_title();
        ?>
</h4>
					<div class="author_date">
						<?php 
        if (class_exists('coauthors_plus')) {
            $co_authors = get_coauthors();
            echo 'Posted by: ';
            foreach ($co_authors as $key => $co_author) {
                $co_author_classes = array('co-author-wrap', 'co-author-number-' . ($key + 1));
                echo '<a href="', get_author_posts_url($co_author->ID), '">', userphoto_thumbnail($co_author), ' ', $co_author->display_name, '</a>';
                if (end($co_authors) !== $co_author) {
                    echo ' and ';
                    // not the last element
                }
            }
        } else {
            echo 'Posted by ';
            echo '<a href="', get_author_posts_url(get_the_author_meta('ID')), '">', userphoto_the_author_thumbnail(), '&nbsp;', the_author_meta('display_name'), '</a>';
        }
        echo '<br />on ';
        echo the_date();
Example #30
0
function wplms_show_notes_discussion($unit_id)
{
    $notes_style = vibe_get_option('notes_style');
    $unit_comments = vibe_get_option('unit_comments');
    if (isset($notes_style) && is_numeric($notes_style) && is_numeric($unit_comments)) {
        ?>
      <div id="discussion" data-unit="<?php 
        echo $unit_id;
        ?>
">
      <h3 class="heading"><?php 
        _e('Discussion', 'vibe');
        $user_id = get_current_user_id();
        $post_author = get_post_field('post_author', $unit_id, true);
        $post_authors = array($post_author);
        if (function_exists('get_coauthors')) {
            $post_authors = get_coauthors($unit_id);
        }
        if (in_array($user_id, $post_authors) || current_user_can('manage_posts')) {
            edit_post_link(__('Manage', 'vibe'), '', '', $unit_id);
        }
        ?>
      </h3>
      <ol class="commentlist">
          <?php 
        $per_page = get_option('comments_per_page');
        if (!is_numeric($per_page)) {
            $per_page = 5;
        }
        $comments_count = get_comments(array('post_id' => $unit_id, 'count' => true, 'parent' => 0));
        $max = ceil($comments_count / $per_page);
        $offset = 0;
        $comments = get_comments(array('post_id' => $unit_id, 'offset' => 0, 'status' => 'approve'));
        wp_list_comments(array('per_page' => $per_page, 'avatar_size' => 120, 'callback' => 'wplms_unit_comment'), $comments);
        ?>
      </ol>
    <?php 
        if ($comments_count > $per_page) {
            $more = $comments_count - $per_page;
            if ($max > 1) {
                ?>
            <a class="load_more_comments right" data-page="1" data-max="<?php 
                echo $max;
                ?>
" data-per="<?php 
                echo $per_page;
                ?>
"><?php 
                printf(__('Load more (<span>%s</span>)', 'vibe'), $more);
                ?>
</a>
          <?php 
            }
        }
        ?>
      <a class="add_comment"><?php 
        printf(__('Ask Question', 'vibe'), $more);
        ?>
</a>
      <div id="add_unit_comment" class="add_unit_comment_text hide">
        <textarea></textarea>
        <a class="button post_question"><?php 
        _e('Post Question', 'vibe');
        ?>
</a>
        <a class="button cancel"><?php 
        _e('Cancel', 'vibe');
        ?>
</a>
      </div>
      </div>
      <?php 
    }
}