Changeset 152347
- Timestamp:
- 09/05/2009 09:46:43 PM (16 years ago)
- Location:
- microkids-related-posts
- Files:
-
- 12 added
- 6 edited
- 9 copied
-
tags/2.3 (added)
-
tags/2.3/images (copied) (copied from microkids-related-posts/trunk/images)
-
tags/2.3/microkids-related-posts.css (copied) (copied from microkids-related-posts/trunk/microkids-related-posts.css)
-
tags/2.3/microkids-related-posts.js (copied) (copied from microkids-related-posts/trunk/microkids-related-posts.js)
-
tags/2.3/microkids-related-posts.php (copied) (copied from microkids-related-posts/trunk/microkids-related-posts.php)
-
tags/2.3/mrp-search.php (copied) (copied from microkids-related-posts/trunk/mrp-search.php)
-
tags/2.3/readme.txt (copied) (copied from microkids-related-posts/trunk/readme.txt)
-
tags/2.3/screenshot-1.png (copied) (copied from microkids-related-posts/trunk/screenshot-1.png)
-
tags/2.3/screenshot-2.png (copied) (copied from microkids-related-posts/trunk/screenshot-2.png)
-
tags/2.3/screenshot-3.png (copied) (copied from microkids-related-posts/trunk/screenshot-3.png)
-
tags/2.4 (added)
-
tags/2.4/images (added)
-
tags/2.4/images/link.png (added)
-
tags/2.4/microkids-related-posts.css (added)
-
tags/2.4/microkids-related-posts.js (added)
-
tags/2.4/microkids-related-posts.php (added)
-
tags/2.4/mrp-search.php (added)
-
tags/2.4/readme.txt (added)
-
tags/2.4/screenshot-1.png (added)
-
tags/2.4/screenshot-2.png (added)
-
tags/2.4/screenshot-3.png (added)
-
trunk/microkids-related-posts.php (modified) (9 diffs)
-
trunk/mrp-search.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/screenshot-1.png (modified) (previous)
-
trunk/screenshot-2.png (modified) (previous)
-
trunk/screenshot-3.png (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
microkids-related-posts/trunk/microkids-related-posts.php
r91181 r152347 3 3 Plugin Name: Microkid's Related Posts 4 4 Plugin URI: http://www.microkid.net/wordpress/related-posts/ 5 Description: Manually add relatedposts5 Description: Display a set of manually selected related items with your posts 6 6 Author: Microkid 7 Version: 2. 37 Version: 2.4 8 8 Author URI: http://www.microkid.net/ 9 9 … … 79 79 80 80 } 81 81 82 function MRP_inner_custom_box() { 82 83 … … 90 91 if( $post_ID ) { 91 92 92 if( $related_posts = MRP_get_related_posts( $post_ID ) ) { 93 94 foreach( $related_posts as $related_post_id => $related_post_title ) { 95 96 echo '<li id="related-post-'.$related_post_id.'"><span>'.$related_post_title.'</span><span><a class="MRP_deletebtn" onclick="MRP_remove_relationship(\'related-post-'.$related_post_id.'\')">X</a></span>'; 97 echo '<input type="hidden" name="MRP_related_posts[]" value="'.$related_post_id.'" /></li>'; 93 if( $related_posts = MRP_get_related_posts( $post_ID, 1, 0 ) ) { 94 95 foreach( $related_posts as $related_post ) { 96 97 $post_title = $related_post->post_title; 98 if( $related_post->post_type == 'page' ) { 99 $post_title = "[Page] " . $post_title; 100 } 101 if( $related_post->post_status != 'publish' ) { 102 $post_title = $post_title . ' ('.$related_post->post_status.')'; 103 } 104 echo '<li id="related-post-'.$related_post->ID.'"><span>'.$post_title.'</span><span><a class="MRP_deletebtn" onclick="MRP_remove_relationship(\'related-post-'.$related_post->ID.'\')">X</a></span>'; 105 echo '<input type="hidden" name="MRP_related_posts[]" value="'.$related_post->ID.'" /></li>'; 98 106 99 107 } … … 197 205 $related_posts[related_post_id] => related_post_title 198 206 */ 199 function MRP_get_related_posts( $post_id ) {200 207 function MRP_get_related_posts( $post_id, $return_object = false, $hide_unpublished = true ) { 208 201 209 global $wpdb; 202 210 203 211 $options = get_option("MRP_options"); 204 212 205 213 if($options['display_reciprocal']) { 206 214 207 215 // 208 // Newer, faster (and definitely more SQL like) way to fetch related postings 209 // (Thanks Peter Raganitsch @ http://blog.oracleapex.at) 210 // 211 $query = "SELECT wp.ID ". 212 ", wp.post_title ". 213 "FROM ".$wpdb->prefix."post_relationships wpr ". 214 ",".$wpdb->prefix."posts wp ". 215 "WHERE wpr.post1_id = $post_id ". 216 "AND wp.id = wpr.post2_id " . 217 "UNION ALL ". 218 "SELECT wp.ID ". 219 ", wp.post_title ". 220 "FROM ".$wpdb->prefix."post_relationships wpr ". 221 ",".$wpdb->prefix."posts wp ". 222 "WHERE wpr.post2_id = $post_id ". 223 "AND wp.id = wpr.post1_id "; 224 } 225 else { 226 $query = "SELECT wp.ID ". 227 ", wp.post_title ". 228 "FROM ".$wpdb->prefix."post_relationships wpr ". 229 " JOIN ".$wpdb->prefix."posts wp ". 230 " ON wpr.post2_id = wp.ID ". 231 "WHERE wpr.post1_id = $post_id"; 216 // Newer, faster (and definitely more SQL like) way to fetch related postings 217 // (Thanks Peter Raganitsch @ http://blog.oracleapex.at) 218 // 219 $query = "SELECT * ". 220 "FROM ".$wpdb->prefix."post_relationships wpr ". 221 ",".$wpdb->prefix."posts wp ". 222 "WHERE wpr.post1_id = $post_id ". 223 "AND wp.id = wpr.post2_id "; 224 if( $hide_unpublished ) { 225 $query .= "AND wp.post_status = 'publish'"; 226 } 227 $query .= "UNION ALL ". 228 "SELECT * ". 229 "FROM ".$wpdb->prefix."post_relationships wpr ". 230 ",".$wpdb->prefix."posts wp ". 231 "WHERE wpr.post2_id = $post_id ". 232 "AND wp.id = wpr.post1_id "; 233 if( $hide_unpublished ) { 234 $query .= "AND wp.post_status = 'publish'"; 235 } 236 } 237 else { 238 $query = "SELECT * ". 239 "FROM ".$wpdb->prefix."post_relationships wpr ". 240 " JOIN ".$wpdb->prefix."posts wp ". 241 " ON wpr.post2_id = wp.ID ". 242 "WHERE wpr.post1_id = $post_id"; 243 if( $hide_unpublished ) { 244 $query .= " AND wp.post_status = 'publish'"; 245 } 232 246 } 233 247 … … 235 249 236 250 if( $results ) { 237 $related_posts = array(); 238 foreach( $results as $result ) { 239 $related_posts[$result->ID] = $result->post_title; 240 } 241 return $related_posts; 251 if( $return_object ) { 252 return $results; 253 } 254 else { 255 $related_posts = array(); 256 foreach( $results as $result ) { 257 $related_posts[$result->ID] = $result->post_title; 258 } 259 return $related_posts; 260 } 242 261 } 243 262 return false; … … 300 319 $options = get_option("MRP_options"); 301 320 302 $related_posts = MRP_get_related_posts( $post_id );321 $related_posts = MRP_get_related_posts( $post_id, 1, 1 ); 303 322 304 323 if( $related_posts ) { … … 309 328 $output .= "<ul>\n"; 310 329 311 foreach( $related_posts as $related_post _id => $related_post_title) {312 $output .= "<li><a href=\"".get_permalink( $related_post _id )."\" title=\"$related_post_title\">".$related_post_title."</a></li>\n";330 foreach( $related_posts as $related_post ) { 331 $output .= "<li><a href=\"".get_permalink( $related_post->ID )."\" title=\"$related_post_title\">".$related_post->post_title."</a></li>\n"; 313 332 } 314 333 … … 410 429 <input type="hidden" id="MRP_submit" name="MRP_submit" value="1" /> 411 430 <?php 431 } 432 433 434 function MRP_shortcode($atts) { 435 global $post; 436 if( $post->ID ) { 437 return MRP_get_related_posts_html( $post->ID ); 438 } 412 439 } 413 440 … … 535 562 add_filter('the_content', 'MRP_auto_related_posts'); 536 563 564 add_shortcode('related-posts', 'MRP_shortcode'); 565 566 537 567 538 568 ?> -
microkids-related-posts/trunk/mrp-search.php
r91181 r152347 38 38 } 39 39 40 $query = "SELECT ID, post_title, post_type FROM $wpdb->posts WHERE $where AND ( post_type = 'post' OR post_type = 'page' ) AND post_status = 'publish'";40 $query = "SELECT ID, post_title, post_type, post_status FROM $wpdb->posts WHERE $where AND ( post_type = 'post' OR post_type = 'page' ) "; 41 41 if( $_GET['mrp_id'] ) { 42 42 $this_id = (int) $_GET['mrp_id']; … … 58 58 echo "<strong>[Page]</strong> - "; 59 59 } 60 echo $result->post_title.'</a> <a href="'.get_permalink( $result->ID ).'" title="View this post" class="MRP_view_post" target="_blank">›</a></li>'; 60 echo $result->post_title; 61 if( $result->post_status != 'publish') { 62 echo ' ('.$result->post_status.')'; 63 } 64 echo '</a> <a href="'.get_permalink( $result->ID ).'" title="View this post" class="MRP_view_post" target="_blank">›</a></li>'; 61 65 $n++; 62 66 } -
microkids-related-posts/trunk/readme.txt
r95771 r152347 1 1 === Microkid's Related Posts === 2 2 Contributors: microkid 3 Tags: related, posts, seo, content, articles, relevant 3 Tags: related, posts, seo, content, articles, relevant, similar 4 4 Requires at least: 2.5 5 Tested up to: 2. 75 Tested up to: 2.8.4 6 6 Stable tag: trunk 7 7 … … 18 18 = Features = 19 19 20 * Manually search and add related posts21 20 * Easily find posts or pages that might be related to the one you are writing with an integrated AJAX powered search utility 22 21 * Easily add and remove relations with a single click. No page reloads, no pop-ups … … 40 39 41 40 = Does this plugin work with Wordpress versions < 2.5? = 42 No, unfortunatelyit is not yet backward compatible with Wordpress version older than 2.5.41 No, it is not yet backward compatible with Wordpress version older than 2.5. 43 42 44 43 = What will be displayed if there are no related posts? = 45 44 You can use a custom message, or display nothing at all (no text, no code). 46 45 47 = Is there any way to grab the related posts in PHP, so I can display them somewhere else instead of underneath my post? =48 Yes, there is a set of [API functions](http://www.microkid.net/wordpress/related-posts/#API "Microkids Related Posts API functions") available to help you do this.46 = How can I customize the way the related posts are displayed? = 47 There is a set of [API functions](http://www.microkid.net/wordpress/related-posts/#API "Microkids Related Posts API functions") available you can use in your themes. 49 48 50 49 = I'm having trouble using this plugin. How can I reach you? = … … 58 57 59 58 == Change Log == 59 60 = 2.4 = 61 * You can now add drafts and planned posts as related posts, without them appearing on your site before they are properly published. 62 * Added shortcode support - you can now place the [related-posts] shortcode within the content of your post to display the related posts anywhere you want. 63 * (For advanced users) Added a parameter to the MRP_get_related_posts function to optionally get the related posts in an object, so you can easily use it in other plugins or your own custom way of displaying the list of related posts. For documentation on this, see [the API section](http://www.microkid.net/wordpress/related-posts/#API "Microkids Related Posts API functions"). 60 64 61 65 = 2.3 =
Note: See TracChangeset
for help on using the changeset viewer.