Another update for quotes-collection users

Updated. See the latest entry for details.

The latest versions of the Quotes Collection plugin have changed the get-quote function. Here is an updated version of the quotescollection_get_quote function that does not waste randomness.

function quotescollection_get_quote($condition = 0)
{
        global $wpdb;
        $offset = rand( 0, quotescollection_count($condition) );

        $sql = "SELECT quote_id, quote, author, source
                FROM " . $wpdb->prefix . "quotescollection
                WHERE visible = 'yes'";

        if ($condition)
                $sql .= " AND " . $condition;

        $sql .= " LIMIT " . $offset . ", 1";

        $random_quote = $wpdb->get_row($sql, ARRAY_A);
        if ( !empty($random_quote) ) {
                return $random_quote;
        }
        else
                return 0;
}

The shipping version of Quotes Collection uses “ORDER BY  RAND()”, not a big deal, but hey my randomness is precious.

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

2 Responses to “Another update for quotes-collection users”

  1. tomf80 Says:

    I notice your quote box doesn’t have a problem with taking out the escape characters in the quote. Did you have to make a change to the code for this? I used the Quotes Collection plugin as found on WordPress.org and it leaves the \ in with the html it outputs.

  2. tekHedd Says:

    As far as I know, my quote box leaves html in verbatim, and doesn’t escape anything. I haven’t made any other changes! I have to manually remove any HTML bits. This does let me put in italics and so on though.

Leave a Reply

You must be logged in to post a comment.