Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changed some query-related code to prevent interference with other pl…

…ugins
  • Loading branch information...
commit f268cf736147109cd06fb5a961617ede210034b1 1 parent acb3dcb
@matthiassiegel authored
Showing with 37 additions and 26 deletions.
  1. +8 −3 README.md
  2. +6 −3 readme.txt
  3. +11 −8 related.php
  4. +12 −12 styles.css
View
11 README.md
@@ -1,19 +1,19 @@
Related
=======
-A simple 'related posts' plugin that lets you choose the related posts yourself instead of generating the list automatically.
+A simple 'related posts' plugin that lets you select related posts manually instead of automatically generating the list.
Tested on WordPress 2.9 - 3.2.1
Websites:
* [http://wordpress.org/extend/plugins/related/](http://wordpress.org/extend/plugins/related/)
-* [http://chipsandtv.com/articles/wordpress-related-posts](http://chipsandtv.com/articles/wordpress-related-posts)
+* [https://github.com/matthiassiegel/Related](https://github.com/matthiassiegel/Related)
Description
-----------
-A simple 'related posts' plugin that lets you choose the related posts yourself instead of generating the list automatically. Supports any post types in WordPress, including custom ones.
+A simple 'related posts' plugin that lets you select related posts manually instead of automatically generating the list. Supports any post types in WordPress, including custom ones.
Features:
@@ -131,7 +131,12 @@ If you're a developer you are encouraged to submit improvements. Just fork it an
Changelog
---------
+### 1.11wip
+
+* Minor rewrites that may prevent interference with other plugins
+
### 1.1
+
* Bugfix: related posts are now correctly saved (deleted) when all related posts are removed from the current post
* Feature: all post types in WordPress are now supported (including custom ones)
* Improvement: select box now sorts posts by title and displays post type
View
9 readme.txt
@@ -1,16 +1,16 @@
=== Related ===
Contributors: chipsandtv
-Donate link: http://chipsandtv.com/
+Donate link: https://github.com/matthiassiegel/Related
Tags: related posts, related, post
Requires at least: 2.9
Tested up to: 3.2.1
Stable tag: trunk
-A simple 'related posts' plugin that lets you choose the related posts yourself instead of generating the list automatically.
+A simple 'related posts' plugin that lets you select related posts manually instead of automatically generating the list.
== Description ==
-A simple 'related posts' plugin that lets you choose the related posts yourself instead of generating the list automatically. Supports any post types in WordPress, including custom ones.
+A simple 'related posts' plugin that lets you select related posts manually instead of automatically generating the list. Supports any post types in WordPress, including custom ones.
Features:
@@ -125,6 +125,9 @@ If you're a developer you are encouraged to submit improvements. Just fork it on
== Changelog ==
+= 1.11wip =
+* Minor rewrites that may prevent interference with other plugins
+
= 1.1 =
* Bugfix: related posts are now correctly saved (deleted) when all related posts are removed from the current post
* Feature: all post types in WordPress are now supported (including custom ones)
View
19 related.php
@@ -1,14 +1,14 @@
<?php
/*
Plugin Name: Related
-Plugin URI: http://chipsandtv.com/
-Description: A simple 'related posts' plugin that lets you choose the related posts yourself instead of generating the list automatically.
+Plugin URI: https://github.com/matthiassiegel/Related
+Description: A simple 'related posts' plugin that lets you select related posts manually instead of automatically generating the list.
Version: 1.1
Author: Matthias Siegel
-Author URI: http://chipsandtv.com/
+Author URI: https://github.com/matthiassiegel/Related
-Copyright 2010-2011 Matthias Siegel (email: chipsandtv@gmail.com)
+Copyright 2010-2012 Matthias Siegel (email: matthias.siegel@gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -48,7 +48,7 @@ public function __construct() {
protected function defineConstants() {
define('RELATED_VERSION', '1.1');
- define('RELATED_HOME', 'http://chipsandtv.com/');
+ define('RELATED_HOME', 'https://github.com/matthiassiegel/Related');
define('RELATED_FILE', plugin_basename(dirname(__FILE__)));
define('RELATED_ABSPATH', str_replace('\\', '/', WP_PLUGIN_DIR . '/' . plugin_basename(dirname(__FILE__))));
define('RELATED_URLPATH', WP_PLUGIN_URL . '/' . plugin_basename(dirname(__FILE__)));
@@ -105,12 +105,14 @@ public function save($id) {
// Creates the output on the post screen
public function displayMetaBox() {
- global $post_ID;
+ global $post;
+
+ $post_id = $post->ID;
echo '<div id="related-posts">';
// Get related posts if existing
- $related = get_post_meta($post_ID, 'related_posts', true);
+ $related = get_post_meta($post_id, 'related_posts', true);
if (!empty($related)) :
foreach($related as $r) :
@@ -132,7 +134,7 @@ public function displayMetaBox() {
$query = array(
'nopaging' => true,
- 'post__not_in' => array($post_ID),
+ 'post__not_in' => array($post_id),
'post_status' => 'publish',
'posts_per_page' => -1,
'post_type' => 'any',
@@ -151,6 +153,7 @@ public function displayMetaBox() {
endif;
wp_reset_query();
+ wp_reset_postdata();
echo '
</select>
View
24 styles.css
@@ -1,18 +1,18 @@
.related-post {
- font-size: 11px;
- margin: 6px 6px 8px;
- padding: 8px;
- background: #f1f1f1;
- border: 1px solid #dfdfdf;
- cursor: pointer;
-
- border-radius: 4px;
- -webkit-border-radius: 4px;
- -moz-border-radius: 4px;
+ font-size: 11px;
+ margin: 6px 6px 8px;
+ padding: 8px;
+ background: #f1f1f1;
+ border: 1px solid #dfdfdf;
+ cursor: pointer;
+
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
}
.related-post-title {
- padding: 0 30px 0 0;
+ padding: 0 30px 0 0;
}
.related-post a {
- float: right;
+ float: right;
}
Please sign in to comment.
Something went wrong with that request. Please try again.