WordPress.org

Ready to get started?Download WordPress

Forums

Quotes Collection
Patch, for Display All by Author (3 posts)

  1. brockers
    Member
    Posted 3 years ago #

    I was hoping to find a way to display all of my quotes but listing them by author instead of by quote. To solve the problem I made a patch that creates a new shortcode option [quote|allbyauthor]

    I have tested the code and have it working on my site if you want to check it out here: http://www.rockerssoft.org/brockers/vault-quotes

    Here is the patch:

    --- quotes-collection/quotes-collection.php	2010-12-02 22:52:35.000000000 -0600
    +++ quotes-collection-new/quotes-collection.php	2011-03-17 10:15:22.510093789 -0500
    @@ -801,9 +801,12 @@
     	if(!$source) {
     		$sql .= "ORDER BY quote";
     	}
    -	else if($source == "Anonymous" || $source == "anonymous") {
    +	elseif($source == "Anonymous" || $source == "anonymous") {
     		$sql .= "AND (author IS NULL OR author = '' OR author ='Anonymous')";
     	}
    +	elseif($source == "ALLBYAUTHORS") {
    +		$sql .= "ORDER BY author";
    +	}
     	else {
     		$sql .= "AND (source = '{$source}' OR author = '{$source}')";
     	}
    @@ -877,6 +880,10 @@
       if ($start !== FALSE) {
         $text = preg_replace( "/\[quote\|all\]/ie", "quotescollection_displayquotes()", $text );
       }
    +	$start = strpos($text,"[quote|allbyauthor]");
    +  if ($start !== FALSE) {
    +    $text = preg_replace( "/\[quote\|allbyauthor\]/ie", "quotescollection_displayquotes(\"ALLBYAUTHORS\")", $text );
    +  }
     	$start = strpos($text,"[quote|author=");
     	if($start !== FALSE) {
     		$text = preg_replace("/\[quote\|author=(.{1,})?\]/ie", "quotescollection_displayquotes(\"\\1\")", $text);
    @@ -888,7 +895,8 @@
     	$start = strpos($text,"[quote|tags=");
     	if($start !== FALSE) {
     		$text = preg_replace("/\[quote\|tags=(.{1,})?\]/ie", "quotescollection_displayquotes_tags(\"\\1\")", $text);
    -	}	return $text;
    +	}
    +	return $text;
     }
    
     function quotescollection_css_head()

    or you can download the patch here: http://www.rockerssoft.org/brockers/Documents/allbyauthor.patch

    Hopefully someone else will find this useful. Quotes Collection is one WP plugin I simply cannot live without.

    Thanks again SriniG!!

    Bobby

    http://wordpress.org/extend/plugins/quotes-collection/

  2. SriniG
    Member
    Plugin Author

    Posted 3 years ago #

    Bobby, thanks for using the plugin, and thanks for the patch. Hope someone will find this useful.

    The good news is that the upcoming version of the plugin will use the WP shortcode APIs, and there will be an option to specify the order.

  3. brockers
    Member
    Posted 2 years ago #

    Thanks Srini, the new shortcode API works great!

    Bobby

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic