{"id":779,"date":"2010-04-27T13:24:35","date_gmt":"2010-04-27T20:24:35","guid":{"rendered":"http:\/\/162.243.68.163\/blog\/?p=779"},"modified":"2011-07-14T14:15:24","modified_gmt":"2011-07-14T21:15:24","slug":"another-update-for-quotes-collection-users","status":"publish","type":"post","link":"https:\/\/tekhedd.com\/?p=779","title":{"rendered":"Another update for quotes-collection users"},"content":{"rendered":"<p><em>Updated.<\/em> See the <a href=\"http:\/\/162.243.68.163\/?p=1141\">latest entry<\/a> for details.<\/p>\n<p>The latest versions of the <a href=\"http:\/\/wordpress.org\/extend\/plugins\/quotes-collection\/\">Quotes Collection<\/a> plugin have changed the get-quote function. Here is an updated version of the quotescollection_get_quote function that does not waste randomness.<\/p>\n<blockquote>\n<pre>function quotescollection_get_quote($condition = 0)\r\n{\r\n        global $wpdb;\r\n        $offset = rand( 0, quotescollection_count($condition) );\r\n\r\n        $sql = \"SELECT quote_id, quote, author, source\r\n                FROM \" . $wpdb-&gt;prefix . \"quotescollection\r\n                WHERE visible = 'yes'\";\r\n\r\n        if ($condition)\r\n                $sql .= \" AND \" . $condition;\r\n\r\n        $sql .= \" LIMIT \" . $offset . \", 1\";\r\n\r\n        $random_quote = $wpdb-&gt;get_row($sql, ARRAY_A);\r\n        if ( !empty($random_quote) ) {\r\n                return $random_quote;\r\n        }\r\n        else\r\n                return 0;\r\n}<\/pre>\n<\/blockquote>\n<p>The <a href=\"http:\/\/srinig.com\/plugins\/quotes-collection\/\">shipping version of Quotes Collection<\/a> uses &#8220;ORDER BY\u00c2\u00a0 RAND()&#8221;, not a big deal, but hey my randomness is precious.<\/p>\n<blockquote>\n<div id=\"_mcePaste\" style=\"overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;\">http:\/\/wordpress.org\/extend\/plugins\/quotes-collection\/<\/div>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>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 = &#8220;SELECT quote_id, quote, author, source FROM [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-779","post","type-post","status-publish","format-standard","hentry","category-other"],"_links":{"self":[{"href":"https:\/\/tekhedd.com\/index.php?rest_route=\/wp\/v2\/posts\/779","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tekhedd.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tekhedd.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tekhedd.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tekhedd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=779"}],"version-history":[{"count":6,"href":"https:\/\/tekhedd.com\/index.php?rest_route=\/wp\/v2\/posts\/779\/revisions"}],"predecessor-version":[{"id":1149,"href":"https:\/\/tekhedd.com\/index.php?rest_route=\/wp\/v2\/posts\/779\/revisions\/1149"}],"wp:attachment":[{"href":"https:\/\/tekhedd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tekhedd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tekhedd.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}