PluginProbe
FeedWordPress / 2011.0531
FeedWordPress v2011.0531
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
feedwordpress / syndicationdataqueries.class.php

syndicationdataqueries.class.php in FeedWordPress 2011.0531, at syndicationdataqueries.class.php

70 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class SyndicationDataQueries {
3 function SyndicationDataQueries () {
4 add_action('init', array(&$this, 'init'));
5 add_filter('posts_search', array(&$this, 'posts_search'), 10, 2);
6 add_filter('posts_fields', array(&$this, 'posts_fields'), 10, 2);
7 add_filter('posts_request', array(&$this, 'posts_request'), 10, 2);
8 }
9
10 function init () {
11 global $wp;
12 $wp->add_query_var('guid');
13 }
14
15 function posts_request ($sql, &$query) {
16 if ($query->get('fields') == '_synfresh') :
17 FeedWordPress::diagnostic('feed_items:freshness:sql', "SQL: ".$sql);
18 endif;
19 return $sql;
20 }
21
22 function posts_search ($search, &$query) {
23 global $wpdb;
24 if ($guid = $query->get('guid')) :
25 if (strlen(trim($guid)) > 0) :
26 $seek = array($guid);
27 $md5Seek = array();
28
29 // MD5 hashes
30 if (preg_match('/^[0-9a-f]{32}$/i', $guid)) :
31 $md5Seek = array($guid);
32 $seek[] = SyndicatedPost::normalize_guid_prefix().$guid;
33 endif;
34
35 // URLs that are invalid, or that WordPress just doesn't like
36 $nGuid = SyndicatedPost::normalize_guid($guid);
37 if ($guid != $nGuid) :
38 $seek[] = $nGuid;
39 endif;
40
41 // Assemble
42 $guidMatch = "(guid = '".implode("') OR (guid = '", $seek)."')";
43 if (count($md5Seek) > 0) :
44 $guidMatch .= " OR (MD5(guid) = '".implode("') OR (MD5(guid) = '", $md5Seek)."')";
45 endif;
46
47 $search .= $wpdb->prepare(" AND ($guidMatch)");
48 endif;
49 endif;
50 return $search;
51 } /* SyndicationDataQueries::posts_where () */
52
53 function posts_fields ($fields, &$query) {
54 global $wpdb;
55 if ($f = $query->get('fields')) :
56 switch ($f) :
57 case '_synfresh' :
58 $fields = "{$wpdb->posts}.ID, {$wpdb->posts}.guid, {$wpdb->posts}.post_modified_gmt";
59 break;
60 default :
61 // Do nothing.
62 endswitch;
63 endif;
64 return $fields;
65 } /* SyndicationDataQueries::posts_fields () */
66 }
67
68 $SDQ = new SyndicationDataQueries;
69
70