Exemplo n.º 1
0
 function widget($args, $instance)
 {
     // If Co-Authors plus plugin exists display all co-aothor profiles one after another
     if (function_exists('coauthors_posts_links')) {
         $i = new CoAuthorsIterator();
         $cnt = 1;
         while ($i->iterate()) {
             // the iterator overwrites the global authordata variable on each iteration
             $instance['seq'] = $cnt++;
             $instance['isLast'] = $i->is_last();
             $this->_displayAuthor($args, $instance);
         }
     } else {
         // Normal behavior, one author per blog post
         $instance['seq'] = 1;
         $instance['isLast'] = true;
         $this->_displayAuthor($args, $instance);
     }
 }
function coauthors__echo($tag, $type = 'tag', $separators = array(), $tag_args = null, $echo = true)
{
    // Define the standard output separator. Constant support is for backwards compat.
    // @see https://github.com/danielbachhuber/Co-Authors-Plus/issues/12
    $default_before = defined('COAUTHORS_DEFAULT_BEFORE') ? COAUTHORS_DEFAULT_BEFORE : '';
    $default_between = defined('COAUTHORS_DEFAULT_BETWEEN') ? COAUTHORS_DEFAULT_BETWEEN : ', ';
    $default_between_last = defined('COAUTHORS_DEFAULT_BETWEEN_LAST') ? COAUTHORS_DEFAULT_BETWEEN_LAST : __(' and ', 'co-authors-plus');
    $default_after = defined('COAUTHORS_DEFAULT_AFTER') ? COAUTHORS_DEFAULT_AFTER : '';
    if (!isset($separators['before']) || null === $separators['before']) {
        $separators['before'] = apply_filters('coauthors_default_before', $default_before);
    }
    if (!isset($separators['between']) || null === $separators['between']) {
        $separators['between'] = apply_filters('coauthors_default_between', $default_between);
    }
    if (!isset($separators['betweenLast']) || null === $separators['betweenLast']) {
        $separators['betweenLast'] = apply_filters('coauthors_default_between_last', $default_between_last);
    }
    if (!isset($separators['after']) || null === $separators['after']) {
        $separators['after'] = apply_filters('coauthors_default_after', $default_after);
    }
    $output = '';
    $i = new CoAuthorsIterator();
    $output .= $separators['before'];
    $i->iterate();
    do {
        $author_text = '';
        if ('tag' === $type) {
            $author_text = $tag($tag_args);
        } elseif ('field' === $type && isset($i->current_author->{$tag})) {
            $author_text = $i->current_author->{$tag};
        } elseif ('callback' === $type && is_callable($tag)) {
            $author_text = call_user_func($tag, $i->current_author);
        }
        // Fallback to user_login if we get something empty
        if (empty($author_text)) {
            $author_text = $i->current_author->user_login;
        }
        // Append separators
        if ($i->count() - $i->position == 1) {
            // last author or only author
            $output .= $author_text;
        } elseif ($i->count() - $i->position == 2) {
            // second to last
            $output .= $author_text . $separators['betweenLast'];
        } else {
            $output .= $author_text . $separators['between'];
        }
    } while ($i->iterate());
    $output .= $separators['after'];
    if ($echo) {
        echo $output;
    }
    return $output;
}
Exemplo n.º 3
0
function risd_coauthors_posts_links($writer_string, $image_folks_string)
{
    global $post;
    $num_authors = get_post_meta($post->ID, 'number_of_authors', true);
    $co_auth_obj = new CoAuthorsIterator();
    $num_contributors = $co_auth_obj->count();
    # Check that the number_of_authors custom field is valid
    # If not, make everybody a writer
    if (!is_numeric($num_authors) || $num_authors < 1 || $num_authors > $num_contributors) {
        $num_authors = $num_contributors;
    }
    echo $writer_string;
    $count = 0;
    while ($co_auth_obj->iterate()) {
        the_author_posts_link();
        $count++;
        # number of contributors we've displayed
        risd_add_delimiter($image_folks_string, $count, $num_authors, $num_contributors);
    }
}
Exemplo n.º 4
0
 /**
  * 21. This function/shortcode will show all authors on a post
  *
  * @example <code>[show_authors]</code> is the default usage
  * @example <code>[show_authors]</code>
  */
 function show_multiple_authors()
 {
     if (class_exists('CoAuthorsIterator')) {
         $i = new CoAuthorsIterator();
         $return = '';
         $i->iterate();
         $return .= '<a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_the_author_meta('display_name') . '</a>';
         while ($i->iterate()) {
             $return .= $i->is_last() ? ' and ' : ', ';
             $return .= '<a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_the_author_meta('display_name') . '</a>';
         }
         return $return;
     } else {
         //fallback
     }
 }
Exemplo n.º 5
0
        <h2>
            About
            <?php 
            if (function_exists('coauthors_posts_links')) {
                coauthors_posts_links();
            } else {
                the_author_posts_link();
            }
            ?>
        </h2>


        <?php 
            if (function_exists('coauthors')) {
                $i = new CoAuthorsIterator();
                $i->iterate();
                print '<div class="gravatar">' . get_avatar(get_the_author_meta('ID'), $size = '52', $default = 'http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536') . '</div>';
                print '<p class="coauthor">' . get_the_author_meta('description') . '</p>';
                while ($i->iterate()) {
                    print '<div class="gravatar">' . get_avatar(get_the_author_meta('ID'), $size = '52', $default = 'http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536') . '</div>';
                    print '<p class="coauthor">' . get_the_author_meta('description') . '</p>';
                }
            } else {
                print '<p>' . get_the_author_meta('description') . '</p>';
            }
            ?>

    </div>

    <?php 
Exemplo n.º 6
0
function coauthors__return($tag)
{
    $return = array();
    $i = new CoAuthorsIterator();
    if ($i->iterate()) {
        $return[] = $tag();
    }
    while ($i->iterate()) {
        $return[] = $tag();
    }
    echo $after;
}
Exemplo n.º 7
0
            ?>
 Themen</h2>
		<p class="smalltext"><?php 
            the_tags('', ' &middot; ', '');
            ?>
 </p>
	</div>
	<?php 
        }
        ?>
	<div class="sidebar-section">
		<h2 class="smalltitle">
			<?php 
        //Autor(en)
        echo '<img src="' . get_bloginfo('template_directory') . '/images/author16px.png" alt="autor"/> ';
        $authors = new CoAuthorsIterator();
        print $authors->count() == 1 ? 'Der Autor' : 'Die Autoren';
        ?>
		</h2>
		<ul class="smalltext authors">
			<?php 
        coauthors_posts_links('</li><li>', '</li><li>', '<li>', '</li>');
        ?>
		</ul>
	</div>
	<div class="sidebar-section">
		<h2 class="smalltitle"><?php 
        echo '<img src="' . get_bloginfo('template_directory') . '/images/calendar16px.png" alt="kalender"/> ';
        ?>
Datum</h2>
		<?php 
Exemplo n.º 8
0
function coauthors__echo($tag, $between, $betweenLast, $before, $after){
	$i = new CoAuthorsIterator();
	echo $before;
	if($i->iterate())
		$tag();
	while($i->iterate()){
		echo $i->is_last() ? $betweenLast : $between;
		$tag();
	}
	echo $after;
}
/**
 * Replace author_url in oembed endpoint response
 * Since the oembed specification does not allow multiple urls, we'll go with the first coauthor
 *
 * The function is meant as a filter for `get_author_posts_url` function, which it is using as well
 * Recursion is prevented by a simple check agains original attributes passed to the funciton. That
 * also prevents execution in case the only coauthor is real author.
 *
 * This function is hooked only to oembed endpoint and it should stay that way
 */
function wpcom_vip_cap_replace_author_link($link, $author_id, $author_nicename)
{
    //get coauthors and iterate to the first one
    //in case there are no coauthors, the Iterator returns current author
    $i = new CoAuthorsIterator();
    $i->iterate();
    //check if the current $author_id and $author_nicename is not the same as the first coauthor
    if ($i->current_author->ID !== $author_id || $i->current_author->user_nicename !== $author_nicename) {
        //alter the author_url
        $link = get_author_posts_url($i->current_author->ID, $i->current_author->user_nicename);
    }
    return $link;
}