{"id":1398,"date":"2007-09-22T17:05:09","date_gmt":"2007-09-22T14:05:09","guid":{"rendered":"http:\/\/mummila.net\/nuudelisoppa\/index.php\/?p=1398"},"modified":"2007-09-22T17:05:09","modified_gmt":"2007-09-22T14:05:09","slug":"fixing-my-plugins-sql-for-wordpress-23","status":"publish","type":"post","link":"https:\/\/mummila.net\/nuudelisoppa\/2007\/09\/22\/fixing-my-plugins-sql-for-wordpress-23\/","title":{"rendered":"Fixing my plugin&#39;s SQL for WordPress 2.3"},"content":{"rendered":"<p>I just upgraded WordPress to version 2.3 RC 1 at my test blog, and found out that <a href=\"http:\/\/boren.nu\/archives\/2007\/08\/26\/wordpress-23-taxonomy-schema\/\">changes in the taxonomy schema<\/a> break my <a href=\"http:\/\/mummila.net\/nuudelisoppa\/index.php\/?page_id=1352\">Parental Control plugin<\/a> in a nasty way. Fortunately, it was quite easy to fix.<\/p>\n<p>I added a test for WordPress&#8217; version and branched the SQL accordingly:<\/p>\n<blockquote>\n<p><pre><code>if (version_compare(get_bloginfo('version'), '2.3-RC1', '&lt;&#039;)) {\n\t<span>$text .= \" AND ( '\".$jupc_excluded_cat.\"'  ALL (SELECT category_id FROM $wpdb-&gt;post2cat WHERE $wpdb-&gt;post2cat.post_id = $wpdb-&gt;posts.ID) )\";<\/span>\n}\nelse {\n\t<span>$text .= \" AND ( '\".$jupc_excluded_cat.\"'  ALL (SELECT term_taxonomy_id FROM $wpdb-&gt;term_relationships WHERE $wpdb-&gt;term_relationships.object_id = $wpdb-&gt;posts.ID) )\";<\/span>\n}<\/code><\/pre>\n<\/p>\n<\/blockquote>\n<p>The code above reserved for versions 2.3 RC1 and above would probably work with the 2.3 Betas as well, but as I don&#8217;t have any interest in testing already obsolete versions, I decided to draw the line to 2.3 RC1, so the code above probably won&#8217;t work with 2.3 trunk versions below RC1.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just upgraded WordPress to version 2.3 RC 1 at my test blog, and found out that changes in the taxonomy schema break my Parental Control plugin in a nasty way. Fortunately, it was quite easy to fix. I added a test for WordPress&#8217; version and branched the SQL accordingly: if (version_compare(get_bloginfo(&#8216;version&#8217;), &#8216;2.3-RC1&#8217;, &#8216;&lt;&#039;)) { [&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":[9387,30,26],"class_list":["post-1398","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-blog","tag-bugsglitches","tag-open-source"],"_links":{"self":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/1398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/comments?post=1398"}],"version-history":[{"count":0,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/1398\/revisions"}],"wp:attachment":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/media?parent=1398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/categories?post=1398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/tags?post=1398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}