PluginProbe
FeedWordPress / 2013.0504
FeedWordPress v2013.0504
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
← All changes | feedwordpresslocalpost.class.php +9 -82 trunk2013.0504 View file →
@@ -1,10 +1,9 @@
1 1 <?php
2 2
3 3 class FeedWordPressLocalPost {
4 - public $post;
5 - public $link;
6 -
4 + private $post;
5 +
7 6 public function __construct ($p = NULL) {
8 7 global $post;
9 8
10 9 if (is_null($p)) :
@@ -16,14 +15,10 @@
16 15 endif;
17 16 }
18 17
19 18 public function id () {
20 - if (is_null($this->post) or !is_object($this->post)) :
21 - return NULL;
22 - else :
23 - return $this->post->ID;
24 - endif;
25 - } /* FeedWordPressLocalPost::id () */
19 + return $this->post->ID;
20 + }
26 21
27 22 public function meta ($what, $params = array()) {
28 23
29 24 // -=-=-= 1. INITIAL SETUP. =-=-=-
@@ -34,14 +29,8 @@
34 29 "unproxied setting" => NULL,
35 30 "unproxy" => false,
36 31 ));
37 32
38 - // If we got put through the_content without a current
39 - // $post object set, then bail out immediately.
40 - if (is_null($this->post) or !is_object($this->post)) :
41 - return $params['default'];
42 - endif;
43 -
44 33 // This is a little weird, just bear with me here.
45 34 $results = array();
46 35
47 36 // Has this been left up to the admin setting?
@@ -53,9 +42,9 @@
53 42
54 43 // Now if we are supposed to look for ultimate source data (e.g. from
55 44 // <atom:source> ... </atom:source> elements), do so here.
56 45 if ($params['unproxy']) :
57 - if ( !is_string($params['unproxied setting'])) :
46 + if (!is_string($params['unproxied setting'])) :
58 47 // Default pattern for unproxied settings: {$name}_original
59 48 $params['unproxied setting'] = $what . '_original';
60 49 endif;
61 50
@@ -72,9 +61,9 @@
72 61
73 62 // -=-=-= 3. DEAL WITH THE RESULTS, IF ANY, OR FALLBACK VALUES. =-=-=-
74 63
75 64 // If we have results now, cool. Just pass them back.
76 - if ( !empty($results)) :
65 + if (!empty($results)) :
77 66 $ret = ($params['single'] ? $results[0] : $results);
78 67
79 68 // If we got no results but we have a fallback global setting, cool. Use
80 69 // that. Jam it into a singleton array for queries expecting an array of
@@ -93,9 +82,9 @@
93 82 return $ret;
94 83 }
95 84
96 85 public function is_syndicated () {
97 - return ( !is_null($this->feed_id(/*single=*/ false)));
86 + return (!is_null($this->feed_id(/*single=*/ false)));
98 87 }
99 88
100 89 public function syndication_permalink () {
101 90 return $this->meta('syndication_permalink');
@@ -102,12 +91,9 @@
102 91 }
103 92
104 93 public function feed () {
105 94 global $feedwordpress;
106 - if (is_object($feedwordpress) and method_exists($feedwordpress, 'subscription')) :
107 - $this->link = $feedwordpress->subscription($this->feed_id());
108 - endif;
109 - return $this->link;
95 + return $feedwordpress->subscription($this->feed_id());
110 96 }
111 97
112 98 public function feed_id () {
113 99 return $this->meta('syndication_feed_id');
@@ -145,9 +131,9 @@
145 131
146 132 public function is_exposed_to_formatting_filters () {
147 133
148 134 return (
149 - ! $this->is_syndicated()
135 + !$this->is_syndicated()
150 136 or (
151 137 'yes' == $this->meta(
152 138 '_feedwordpress_formatting_filters',
153 139 array(
@@ -158,66 +144,7 @@
158 144 )
159 145 );
160 146
161 147 } /* FeedWordPressLocalPost::is_exposed_to_formatting_filters () */
162 -
163 -
164 - public function content () {
165 - if (is_null($this->post) or !is_object($this->post)) :
166 - $post_content = NULL;
167 - $post_id = NULL;
168 - else :
169 - $post_content = $this->post->post_content;
170 - $post_id = $this->post->ID;
171 - endif;
172 - return apply_filters('the_content', $post_content, $post_id);
173 - }
174 -
175 - public function title () {
176 - if (is_null($this->post) or !is_object($this->post)) :
177 - $post_title = NULL;
178 - $post_id = NULL;
179 - else :
180 - $post_title = $this->post->post_title;
181 - $post_id = $this->post->ID;
182 - endif;
183 - return apply_filters('the_title', $post_title, $post_id);
184 - }
185 -
186 - public function guid () {
187 - if (is_null($this->post) or !is_object($this->post)) :
188 - $post_guid = NULL;
189 - else :
190 - $post_guid = $this->post->guid;
191 - endif;
192 - return apply_filters('get_the_guid', $post_guid);
193 - }
194 -
195 - public function get_categories () {
196 - if (is_null($this->post) or !is_object($this->post)) :
197 - return array();
198 - endif;
199 -
200 - $terms = wp_get_object_terms(
201 - $this->post->ID,
202 - get_taxonomies(array(
203 - 'public' => true,
204 - ), 'names'),
205 - 'all'
206 - );
207 - $rootUrl = get_bloginfo('url');
208 -
209 - $cats = array();
210 - foreach ($terms as $term) :
211 - $taxUrl = MyPHP::url($rootUrl, array("taxonomy" => $term->taxonomy));
212 - //array("taxonomy" => $term->taxonomy ));
213 - $cats[] = new SimplePie_Category(
214 - /*term=*/ $term->slug,
215 - /*scheme=*/ $taxUrl,
216 - /*label=*/ $term->name
217 - );
218 - endforeach;
219 - return $cats;
220 - }
221 148
222 149 } /* class FeedWordPressLocalPost */
223 150