WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
Feature: Iterator Filter (2 posts)

  1. h0tw1r3
    Member
    Posted 2 years ago #

    Co-authors-plus is a great plugin! Thanks for all the hard work.

    I would like to suggest one feature, a filter to the iterator. Currently I apply WP's 'the_author' filter, but any filter hook would be very convenient.

    --- a/wp-content/plugins/co-authors-plus/template-tags.php
    +++ b/wp-content/plugins/co-authors-plus/template-tags.php
    @@ -145,6 +145,16 @@ function coauthors__echo( $tag, $type = 'tag', $separators = array(), $tag_args
     		if( empty( $author_text ) )
     			$author_text = $i->current_author->user_login;
    
    +		/*
    +		 * CUSTOMIZATION: Apply wordpress filter
    +		 */
    +		$author_text = apply_filters( 'the_author', $author_text );
    +		if ( empty( $author_text ) ) {
    +			$i->count = $i->count - 1;
    +			$i->position = $i-position - 1;
    +			continue;
    +		}
    +
     		// Append separators
     		if ( ! $i->is_first() && $i->count() > 2 )
     			$output .= $separators['between'];
  2. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 2 years ago #

    Sounds reasonable :) Want to prepare a pull request for this on Github?

    My preference would be to apply a filter called 'the_coauthor', and then you can hook whatever you'd like onto that.

    Also, make sure your code actually executes (e.g. "$i-position" looks broken), and you can decrement with $i->position-- or similar.

    Lastly, if you could prepare an example use case when you submit your pull request so I can properly test, that'd be wonderful.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic