Changeset 525505
- Timestamp:
- 03/31/2012 12:41:07 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ntrsctn-content-aggregator/trunk/ntrsctn-aggregator.php
r525138 r525505 188 188 } 189 189 190 function ntrsctn_comments_enabled($post ) {190 function ntrsctn_comments_enabled($post=null) { 191 191 $ntrsctn_remote_comments_on = get_option('ntrsctn_json_api_remote_comments_on', DEFAULT_AGGREGATOR_REMOTE_COMMENTS_ON); 192 192 if (!$ntrsctn_remote_comments_on) { … … 199 199 if (empty($comments_url) || empty($shortname)) { 200 200 return false; 201 } 202 203 if (empty($post)) { 204 return true; 201 205 } 202 206 … … 217 221 $comments_url = trim(get_option('ntrsctn_comments_url', DEFAULT_NTRSCTN_COMMENTS_URL)); 218 222 $shortname = get_option('ntrsctn_json_api_shortname', ''); 219 220 // @todo comments should always be close so this not necessary221 if (!comments_open()) {222 print "<h2>Comments Closed</h2>";223 return $comments;224 }225 223 226 224 if (!ntrsctn_comments_enabled($wp_query->post)) { … … 249 247 /* Hide the WordPress commenting form 250 248 /*****************************/ 251 #respond, #commentform, #addcomment, .entry-comments {249 #respond, #commentform, #addcomment, .entry-comments, .nocomments { 252 250 display: none; 253 251 } … … 265 263 } 266 264 267 // @todo cache fetch number of comments from comment server 265 $post_id = $wp_query->post->ID; 266 $transient = 'ntrsctn_c_'.$post_id; 267 $result = get_transient($transient); 268 if ($result !== false) { 269 return $result; 270 } 268 271 269 272 $comments_url = trim(get_option('ntrsctn_comments_url', DEFAULT_NTRSCTN_COMMENTS_URL)); … … 271 274 $params = array( 272 275 'shortname' => $shortname, 273 'post_id' => $ wp_query->post->ID276 'post_id' => $post_id 274 277 ); 275 278 … … 282 285 curl_close($ch); 283 286 284 return $result > 0 ? $result : 0; 287 $result = $result > 0 ? $result : 0; 288 // cache the number of comments on this article for 60 seconds 289 set_transient($transient, $result, 60); 290 return $result; 285 291 } 286 292 … … 304 310 305 311 // Add a filter to replace wordpress comments with ntrsctn comments 306 // @todo add preference to use ntrsctn comments307 // @todo add preference to use ntrsctn comments if posted after time X308 312 $ntrsctn_remote_comments_on = get_option('ntrsctn_json_api_remote_comments_on', DEFAULT_AGGREGATOR_REMOTE_COMMENTS_ON); 309 313 if ($ntrsctn_remote_comments_on) {
Note: See TracChangeset
for help on using the changeset viewer.