Version Description
- Added complete localization support
- Added button to recreate the mySQL FULLTEXT index
Download this release
Release Info
Developer | Ajay |
Plugin | Contextual Related Posts |
Version | 1.4 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.4
- admin.inc.php +45 -23
- contextual-related-posts.php +48 -17
- languages/crp-en_US.mo +0 -0
- languages/crp-en_US.po +129 -0
- languages/crp-en_US.pot +129 -0
- readme.txt +35 -20
- uninstall.php +7 -0
admin.inc.php
CHANGED
@@ -2,6 +2,10 @@
|
|
2 |
/**********************************************************************
|
3 |
* Admin Page *
|
4 |
*********************************************************************/
|
|
|
|
|
|
|
|
|
5 |
// Pre-2.6 compatibility
|
6 |
if ( !defined('WP_CONTENT_URL') )
|
7 |
define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
|
@@ -42,7 +46,7 @@ function crp_options() {
|
|
42 |
|
43 |
update_option('ald_crp_settings', $crp_settings);
|
44 |
|
45 |
-
$str = '<div id="message" class="updated fade"><p>'. __('Options saved successfully.',
|
46 |
echo $str;
|
47 |
}
|
48 |
|
@@ -51,48 +55,63 @@ function crp_options() {
|
|
51 |
$crp_settings = crp_default_options();
|
52 |
update_option('ald_crp_settings', $crp_settings);
|
53 |
|
54 |
-
$str = '<div id="message" class="updated fade"><p>'. __('Options set to Default.',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
echo $str;
|
56 |
}
|
57 |
?>
|
58 |
|
59 |
<div class="wrap">
|
60 |
-
<h2>Contextual Related Posts
|
61 |
<div style="border: #ccc 1px solid; padding: 10px">
|
62 |
<fieldset class="options">
|
63 |
<legend>
|
64 |
<h3>
|
65 |
-
<?php _e('Support the Development',
|
66 |
</h3>
|
67 |
</legend>
|
68 |
<p>
|
69 |
-
<?php _e('If you find ',
|
70 |
<a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a>
|
71 |
-
<?php _e('useful, please do',
|
72 |
-
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=donate@ajaydsouza.com&item_name=Related%20Posts%20(From%20WP-Admin)&no_shipping=1&return=http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/&cancel_return=http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/&cn=Note%20to%20Author&tax=0&currency_code=USD&bn=PP-DonationsBF&charset=UTF-8" title="Donate via PayPal"><?php _e('drop in your contribution',
|
73 |
-
(<a href="http://ajaydsouza.com/donate/"><?php _e('Some reasons why you should.',
|
74 |
</fieldset>
|
75 |
</div>
|
76 |
<form method="post" id="crp_options" name="crp_options" style="border: #ccc 1px solid; padding: 10px" onsubmit="return checkForm()">
|
77 |
<fieldset class="options">
|
78 |
<legend>
|
79 |
<h3>
|
80 |
-
<?php _e('Options:',
|
81 |
</h3>
|
82 |
</legend>
|
83 |
<p>
|
84 |
<label>
|
85 |
-
<?php _e('Number of related posts to display: ',
|
86 |
<input type="textbox" name="limit" id="limit" value="<?php echo stripslashes($crp_settings[limit]); ?>">
|
87 |
</label>
|
88 |
</p>
|
89 |
<p>
|
90 |
<label>
|
91 |
-
<?php _e('Title of related posts: ',
|
92 |
<input type="textbox" name="title" id="title" value="<?php echo stripslashes($crp_settings[title]); ?>">
|
93 |
</label>
|
94 |
</p>
|
95 |
-
<p><?php _e('Exclude Categories: ',
|
96 |
<div style="position:relative;text-align:left">
|
97 |
<table id="MYCUSTOMFLOATER" class="myCustomFloater" style="position:absolute;top:50px;left:0;background-color:#cecece;display:none;visibility:hidden">
|
98 |
<tr><td><!--
|
@@ -107,49 +126,50 @@ function crp_options() {
|
|
107 |
</table>
|
108 |
<textarea class="wickEnabled:MYCUSTOMFLOATER" cols="50" rows="3" wrap="virtual" name="exclude_cat_slugs"><?php echo stripslashes($crp_settings[exclude_cat_slugs]); ?></textarea>
|
109 |
</div>
|
110 |
-
<p><?php _e('When there are no posts, what should be shown?',
|
111 |
<label>
|
112 |
<input type="radio" name="blank_output" value="blank" id="blank_output_0" <?php if ($crp_settings['blank_output']) echo 'checked="checked"' ?> />
|
113 |
-
<?php _e('Blank Output',
|
114 |
<br />
|
115 |
<label>
|
116 |
<input type="radio" name="blank_output" value="noposts" id="blank_output_1" <?php if (!$crp_settings['blank_output']) echo 'checked="checked"' ?> />
|
117 |
-
<?php _e('Display "No Related Posts"',
|
118 |
<br />
|
119 |
</p>
|
120 |
<p>
|
121 |
<label>
|
122 |
<input type="checkbox" name="add_to_content" id="add_to_content" <?php if ($crp_settings[add_to_content]) echo 'checked="checked"' ?> />
|
123 |
-
<?php _e('Add related posts to the post content on single posts. <br />If you choose to disable this, please add <code><?php if(function_exists(\'echo_ald_crp\')) echo_ald_crp(); ?></code> to your template file where you want it displayed',
|
124 |
</label>
|
125 |
</p>
|
126 |
<p>
|
127 |
<label>
|
128 |
<input type="checkbox" name="add_to_page" id="add_to_page" <?php if ($crp_settings[add_to_page]) echo 'checked="checked"' ?> />
|
129 |
-
<?php _e('Add related posts to pages. <br />If you choose to disable this, please add <code><?php if(function_exists(\'echo_ald_crp\')) echo_ald_crp(); ?></code> to your template file where you want it displayed',
|
130 |
</label>
|
131 |
</p>
|
132 |
<p>
|
133 |
<label>
|
134 |
<input type="checkbox" name="add_to_feed" id="add_to_feed" <?php if ($crp_settings[add_to_feed]) echo 'checked="checked"' ?> />
|
135 |
-
<?php _e('Add related posts to feed',
|
136 |
</label>
|
137 |
</p>
|
138 |
<p>
|
139 |
<label>
|
140 |
<input type="checkbox" name="match_content" id="match_content" <?php if ($crp_settings[match_content]) echo 'checked="checked"' ?> />
|
141 |
-
<?php _e('Find related posts based on content as well as title. If unchecked, only posts titles are used. (I recommend using a caching plugin if you enable this)',
|
142 |
</label>
|
143 |
</p>
|
144 |
<p>
|
145 |
<label>
|
146 |
<input type="checkbox" name="exclude_pages" id="exclude_pages" <?php if ($crp_settings[exclude_pages]) echo 'checked="checked"' ?> />
|
147 |
-
<?php _e('Exclude Pages in Related Posts',
|
148 |
</label>
|
149 |
</p>
|
150 |
<p>
|
151 |
-
<input type="submit" name="crp_save" id="crp_save" value="Save Options" style="border:#
|
152 |
-
<input name="crp_default" type="submit" id="crp_default" value="Default Options" style="border:#
|
|
|
153 |
</p>
|
154 |
</fieldset>
|
155 |
</form>
|
@@ -174,9 +194,11 @@ function crp_adminmenu() {
|
|
174 |
}
|
175 |
|
176 |
if ((function_exists('add_options_page'))&&($crp_is_admin)) {
|
177 |
-
$plugin_page = add_options_page(__("Related Posts",
|
178 |
add_action( 'admin_head-'. $plugin_page, 'crp_adminhead' );
|
179 |
}
|
|
|
|
|
180 |
}
|
181 |
add_action('admin_menu', 'crp_adminmenu');
|
182 |
|
2 |
/**********************************************************************
|
3 |
* Admin Page *
|
4 |
*********************************************************************/
|
5 |
+
if (!defined('ABSPATH')) die("Aren't you supposed to come here via WP-Admin?");
|
6 |
+
|
7 |
+
if (!defined('CRP_LOCAL_NAME')) define('CRP_LOCAL_NAME', 'better-search');
|
8 |
+
|
9 |
// Pre-2.6 compatibility
|
10 |
if ( !defined('WP_CONTENT_URL') )
|
11 |
define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
|
46 |
|
47 |
update_option('ald_crp_settings', $crp_settings);
|
48 |
|
49 |
+
$str = '<div id="message" class="updated fade"><p>'. __('Options saved successfully.',CRP_LOCAL_NAME) .'</p></div>';
|
50 |
echo $str;
|
51 |
}
|
52 |
|
55 |
$crp_settings = crp_default_options();
|
56 |
update_option('ald_crp_settings', $crp_settings);
|
57 |
|
58 |
+
$str = '<div id="message" class="updated fade"><p>'. __('Options set to Default.',CRP_LOCAL_NAME) .'</p></div>';
|
59 |
+
echo $str;
|
60 |
+
}
|
61 |
+
if ($_POST['crp_recreate']){
|
62 |
+
$sql = "ALTER TABLE $poststable DROP INDEX crp_related";
|
63 |
+
$wpdb->query($sql);
|
64 |
+
|
65 |
+
$sql = "ALTER TABLE $poststable DROP INDEX crp_related_title";
|
66 |
+
$wpdb->query($sql);
|
67 |
+
|
68 |
+
$sql = "ALTER TABLE $poststable DROP INDEX crp_related_content";
|
69 |
+
$wpdb->query($sql);
|
70 |
+
|
71 |
+
ald_crp_activate();
|
72 |
+
|
73 |
+
$str = '<div id="message" class="updated fade"><p>'. __('Index recreated',CRP_LOCAL_NAME) .'</p></div>';
|
74 |
echo $str;
|
75 |
}
|
76 |
?>
|
77 |
|
78 |
<div class="wrap">
|
79 |
+
<h2>Contextual Related Posts</h2>
|
80 |
<div style="border: #ccc 1px solid; padding: 10px">
|
81 |
<fieldset class="options">
|
82 |
<legend>
|
83 |
<h3>
|
84 |
+
<?php _e('Support the Development',CRP_LOCAL_NAME); ?>
|
85 |
</h3>
|
86 |
</legend>
|
87 |
<p>
|
88 |
+
<?php _e('If you find ',CRP_LOCAL_NAME); ?>
|
89 |
<a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a>
|
90 |
+
<?php _e('useful, please do',CRP_LOCAL_NAME); ?>
|
91 |
+
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=donate@ajaydsouza.com&item_name=Related%20Posts%20(From%20WP-Admin)&no_shipping=1&return=http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/&cancel_return=http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/&cn=Note%20to%20Author&tax=0&currency_code=USD&bn=PP-DonationsBF&charset=UTF-8" title="Donate via PayPal"><?php _e('drop in your contribution',CRP_LOCAL_NAME); ?></a>.
|
92 |
+
(<a href="http://ajaydsouza.com/donate/"><?php _e('Some reasons why you should.',CRP_LOCAL_NAME); ?></a>)</p>
|
93 |
</fieldset>
|
94 |
</div>
|
95 |
<form method="post" id="crp_options" name="crp_options" style="border: #ccc 1px solid; padding: 10px" onsubmit="return checkForm()">
|
96 |
<fieldset class="options">
|
97 |
<legend>
|
98 |
<h3>
|
99 |
+
<?php _e('Options:',CRP_LOCAL_NAME); ?>
|
100 |
</h3>
|
101 |
</legend>
|
102 |
<p>
|
103 |
<label>
|
104 |
+
<?php _e('Number of related posts to display: ',CRP_LOCAL_NAME); ?>
|
105 |
<input type="textbox" name="limit" id="limit" value="<?php echo stripslashes($crp_settings[limit]); ?>">
|
106 |
</label>
|
107 |
</p>
|
108 |
<p>
|
109 |
<label>
|
110 |
+
<?php _e('Title of related posts: ',CRP_LOCAL_NAME); ?>
|
111 |
<input type="textbox" name="title" id="title" value="<?php echo stripslashes($crp_settings[title]); ?>">
|
112 |
</label>
|
113 |
</p>
|
114 |
+
<p><?php _e('Exclude Categories: ',CRP_LOCAL_NAME); ?></p>
|
115 |
<div style="position:relative;text-align:left">
|
116 |
<table id="MYCUSTOMFLOATER" class="myCustomFloater" style="position:absolute;top:50px;left:0;background-color:#cecece;display:none;visibility:hidden">
|
117 |
<tr><td><!--
|
126 |
</table>
|
127 |
<textarea class="wickEnabled:MYCUSTOMFLOATER" cols="50" rows="3" wrap="virtual" name="exclude_cat_slugs"><?php echo stripslashes($crp_settings[exclude_cat_slugs]); ?></textarea>
|
128 |
</div>
|
129 |
+
<p><?php _e('When there are no posts, what should be shown?',CRP_LOCAL_NAME); ?><br />
|
130 |
<label>
|
131 |
<input type="radio" name="blank_output" value="blank" id="blank_output_0" <?php if ($crp_settings['blank_output']) echo 'checked="checked"' ?> />
|
132 |
+
<?php _e('Blank Output',CRP_LOCAL_NAME); ?></label>
|
133 |
<br />
|
134 |
<label>
|
135 |
<input type="radio" name="blank_output" value="noposts" id="blank_output_1" <?php if (!$crp_settings['blank_output']) echo 'checked="checked"' ?> />
|
136 |
+
<?php _e('Display "No Related Posts"',CRP_LOCAL_NAME); ?></label>
|
137 |
<br />
|
138 |
</p>
|
139 |
<p>
|
140 |
<label>
|
141 |
<input type="checkbox" name="add_to_content" id="add_to_content" <?php if ($crp_settings[add_to_content]) echo 'checked="checked"' ?> />
|
142 |
+
<?php _e('Add related posts to the post content on single posts. <br />If you choose to disable this, please add <code><?php if(function_exists(\'echo_ald_crp\')) echo_ald_crp(); ?></code> to your template file where you want it displayed',CRP_LOCAL_NAME); ?>
|
143 |
</label>
|
144 |
</p>
|
145 |
<p>
|
146 |
<label>
|
147 |
<input type="checkbox" name="add_to_page" id="add_to_page" <?php if ($crp_settings[add_to_page]) echo 'checked="checked"' ?> />
|
148 |
+
<?php _e('Add related posts to pages. <br />If you choose to disable this, please add <code><?php if(function_exists(\'echo_ald_crp\')) echo_ald_crp(); ?></code> to your template file where you want it displayed',CRP_LOCAL_NAME); ?>
|
149 |
</label>
|
150 |
</p>
|
151 |
<p>
|
152 |
<label>
|
153 |
<input type="checkbox" name="add_to_feed" id="add_to_feed" <?php if ($crp_settings[add_to_feed]) echo 'checked="checked"' ?> />
|
154 |
+
<?php _e('Add related posts to feed',CRP_LOCAL_NAME); ?>
|
155 |
</label>
|
156 |
</p>
|
157 |
<p>
|
158 |
<label>
|
159 |
<input type="checkbox" name="match_content" id="match_content" <?php if ($crp_settings[match_content]) echo 'checked="checked"' ?> />
|
160 |
+
<?php _e('Find related posts based on content as well as title. If unchecked, only posts titles are used. (I recommend using a caching plugin if you enable this)',CRP_LOCAL_NAME); ?>
|
161 |
</label>
|
162 |
</p>
|
163 |
<p>
|
164 |
<label>
|
165 |
<input type="checkbox" name="exclude_pages" id="exclude_pages" <?php if ($crp_settings[exclude_pages]) echo 'checked="checked"' ?> />
|
166 |
+
<?php _e('Exclude Pages in Related Posts',CRP_LOCAL_NAME); ?>
|
167 |
</label>
|
168 |
</p>
|
169 |
<p>
|
170 |
+
<input type="submit" name="crp_save" id="crp_save" value="Save Options" style="border:#0C0 1px solid" />
|
171 |
+
<input name="crp_default" type="submit" id="crp_default" value="Default Options" style="border:#F00 1px solid" onclick="if (!confirm('<?php _e('Do you want to set options to Default? If you don\'t have a copy of the username, please hit Cancel and copy it first.',CRP_LOCAL_NAME); ?>')) return false;" />
|
172 |
+
<input name="crp_recreate" type="submit" id="crp_recreate" value="Recreate index" style="border:#00c 1px solid" onclick="if (!confirm('<?php _e('Are you sure you want to recreate the index?',CRP_LOCAL_NAME); ?>')) return false;" />
|
173 |
</p>
|
174 |
</fieldset>
|
175 |
</form>
|
194 |
}
|
195 |
|
196 |
if ((function_exists('add_options_page'))&&($crp_is_admin)) {
|
197 |
+
$plugin_page = add_options_page(__("Related Posts", CRP_LOCAL_NAME), __("Related Posts", CRP_LOCAL_NAME), 9, 'crp_options', 'crp_options');
|
198 |
add_action( 'admin_head-'. $plugin_page, 'crp_adminhead' );
|
199 |
}
|
200 |
+
|
201 |
+
ald_crp_activate();
|
202 |
}
|
203 |
add_action('admin_menu', 'crp_adminmenu');
|
204 |
|
contextual-related-posts.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Contextual Related Posts
|
4 |
-
Version: 1.
|
5 |
Plugin URI: http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/
|
6 |
Description: Show user defined number of contextually related posts. Based on the plugin by <a href="http://weblogtoolscollection.com">Mark Ghosh</a>. <a href="options-general.php?page=crp_options">Configure...</a>
|
7 |
Author: Ajay D'Souza
|
@@ -10,12 +10,19 @@ Author URI: http://ajaydsouza.com/
|
|
10 |
|
11 |
if (!defined('ABSPATH')) die("Aren't you supposed to come here via WP-Admin?");
|
12 |
|
|
|
|
|
|
|
13 |
function ald_crp_init() {
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
add_action('init', 'ald_crp_init');
|
17 |
|
18 |
-
define('ALD_crp_DIR', dirname(__FILE__));
|
19 |
|
20 |
/*********************************************************************
|
21 |
* Main Function (Do not edit) *
|
@@ -38,18 +45,23 @@ function ald_crp() {
|
|
38 |
$stuff = addslashes($post->post_title);
|
39 |
}
|
40 |
|
41 |
-
$sql = "SELECT DISTINCT ID,post_title,post_date,"
|
42 |
-
. "MATCH(post_title,post_content) AGAINST ('$stuff') AS score "
|
43 |
-
. "FROM $wpdb->posts WHERE "
|
44 |
-
. "MATCH (post_title,post_content) AGAINST ('$stuff') "
|
45 |
-
. "AND post_date <= '$now' "
|
46 |
-
. "AND post_status = 'publish' "
|
47 |
-
. "AND id != $post->ID ";
|
48 |
-
if ($crp_settings['exclude_pages']) $sql .= "AND post_type = 'post' ";
|
49 |
-
$sql .= "ORDER BY score DESC ";
|
50 |
|
51 |
-
$
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
$output = '<div id="crp_related">';
|
55 |
|
@@ -74,11 +86,11 @@ function ald_crp() {
|
|
74 |
$output .= '</ul>';
|
75 |
}else{
|
76 |
$output = '<div id="crp_related">';
|
77 |
-
$output .= ($crp_settings['blank_output']) ? ' ' : '<p>'.__('No related posts found',
|
78 |
}
|
79 |
if ((strpos($output, '<li>')) === false) {
|
80 |
$output = '<div id="crp_related">';
|
81 |
-
$output .= ($crp_settings['blank_output']) ? ' ' : '<p>'.__('No related posts found',
|
82 |
}
|
83 |
$output .= '</div>';
|
84 |
|
@@ -110,7 +122,7 @@ function echo_ald_crp() {
|
|
110 |
|
111 |
// Default Options
|
112 |
function crp_default_options() {
|
113 |
-
$title = __('<h3>Related Posts:</h3>');
|
114 |
|
115 |
$crp_settings = Array (
|
116 |
title => $title, // Add before the content
|
@@ -158,6 +170,8 @@ function ald_crp_activate() {
|
|
158 |
$wpdb->hide_errors();
|
159 |
$wpdb->query('ALTER TABLE '.$wpdb->posts.' ENGINE = MYISAM;');
|
160 |
$wpdb->query('ALTER TABLE '.$wpdb->posts.' ADD FULLTEXT crp_related (post_title, post_content);');
|
|
|
|
|
161 |
$wpdb->show_errors();
|
162 |
}
|
163 |
if (function_exists('register_activation_hook')) {
|
@@ -169,5 +183,22 @@ if (is_admin() || strstr($_SERVER['PHP_SELF'], 'wp-admin/')) {
|
|
169 |
require_once(ALD_crp_DIR . "/admin.inc.php");
|
170 |
}
|
171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
?>
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Contextual Related Posts
|
4 |
+
Version: 1.4
|
5 |
Plugin URI: http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/
|
6 |
Description: Show user defined number of contextually related posts. Based on the plugin by <a href="http://weblogtoolscollection.com">Mark Ghosh</a>. <a href="options-general.php?page=crp_options">Configure...</a>
|
7 |
Author: Ajay D'Souza
|
10 |
|
11 |
if (!defined('ABSPATH')) die("Aren't you supposed to come here via WP-Admin?");
|
12 |
|
13 |
+
define('ALD_crp_DIR', dirname(__FILE__));
|
14 |
+
define('CRP_LOCAL_NAME', 'crp');
|
15 |
+
|
16 |
function ald_crp_init() {
|
17 |
+
//* Begin Localization Code */
|
18 |
+
$crp_localizationName = CRP_LOCAL_NAME;
|
19 |
+
$crp_comments_locale = get_locale();
|
20 |
+
$crp_comments_mofile = ALD_crp_DIR . "/languages/" . $crp_localizationName . "-". $crp_comments_locale.".mo";
|
21 |
+
load_textdomain($crp_localizationName, $crp_comments_mofile);
|
22 |
+
//* End Localization Code */
|
23 |
}
|
24 |
add_action('init', 'ald_crp_init');
|
25 |
|
|
|
26 |
|
27 |
/*********************************************************************
|
28 |
* Main Function (Do not edit) *
|
45 |
$stuff = addslashes($post->post_title);
|
46 |
}
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
if (($post->ID != '')||($stuff != '')) {
|
50 |
+
$sql = "SELECT DISTINCT ID,post_title,post_date,"
|
51 |
+
. "MATCH(post_title,post_content) AGAINST ('".$stuff."') AS score "
|
52 |
+
. "FROM ".$wpdb->posts." WHERE "
|
53 |
+
. "MATCH (post_title,post_content) AGAINST ('".$stuff."') "
|
54 |
+
. "AND post_date <= '".$now."' "
|
55 |
+
. "AND post_status = 'publish' "
|
56 |
+
. "AND id != ".$post->ID." ";
|
57 |
+
if ($crp_settings['exclude_pages']) $sql .= "AND post_type = 'post' ";
|
58 |
+
$sql .= "ORDER BY score DESC ";
|
59 |
+
|
60 |
+
$search_counter = 0;
|
61 |
+
$searches = $wpdb->get_results($sql);
|
62 |
+
} else {
|
63 |
+
$searches = false;
|
64 |
+
}
|
65 |
|
66 |
$output = '<div id="crp_related">';
|
67 |
|
86 |
$output .= '</ul>';
|
87 |
}else{
|
88 |
$output = '<div id="crp_related">';
|
89 |
+
$output .= ($crp_settings['blank_output']) ? ' ' : '<p>'.__('No related posts found',CRP_LOCAL_NAME).'</p>';
|
90 |
}
|
91 |
if ((strpos($output, '<li>')) === false) {
|
92 |
$output = '<div id="crp_related">';
|
93 |
+
$output .= ($crp_settings['blank_output']) ? ' ' : '<p>'.__('No related posts found',CRP_LOCAL_NAME).'</p>';
|
94 |
}
|
95 |
$output .= '</div>';
|
96 |
|
122 |
|
123 |
// Default Options
|
124 |
function crp_default_options() {
|
125 |
+
$title = __('<h3>Related Posts:</h3>',CRP_LOCAL_NAME);
|
126 |
|
127 |
$crp_settings = Array (
|
128 |
title => $title, // Add before the content
|
170 |
$wpdb->hide_errors();
|
171 |
$wpdb->query('ALTER TABLE '.$wpdb->posts.' ENGINE = MYISAM;');
|
172 |
$wpdb->query('ALTER TABLE '.$wpdb->posts.' ADD FULLTEXT crp_related (post_title, post_content);');
|
173 |
+
$wpdb->query('ALTER TABLE '.$wpdb->posts.' ADD FULLTEXT crp_related_title (post_title);');
|
174 |
+
$wpdb->query('ALTER TABLE '.$wpdb->posts.' ADD FULLTEXT crp_related_content (post_content);');
|
175 |
$wpdb->show_errors();
|
176 |
}
|
177 |
if (function_exists('register_activation_hook')) {
|
183 |
require_once(ALD_crp_DIR . "/admin.inc.php");
|
184 |
}
|
185 |
|
186 |
+
// Add meta links
|
187 |
+
function crp_plugin_actions( $links, $file ) {
|
188 |
+
$plugin = plugin_basename(__FILE__);
|
189 |
+
|
190 |
+
// create link
|
191 |
+
if ($file == $plugin) {
|
192 |
+
$links[] = '<a href="' . admin_url( 'options-general.php?page=crp_options' ) . '">' . __('Settings', crp_LOCAL_NAME ) . '</a>';
|
193 |
+
$links[] = '<a href="http://ajaydsouza.org">' . __('Support', CRP_LOCAL_NAME ) . '</a>';
|
194 |
+
$links[] = '<a href="http://ajaydsouza.com/donate/">' . __('Donate', CRP_LOCAL_NAME ) . '</a>';
|
195 |
+
}
|
196 |
+
return $links;
|
197 |
+
}
|
198 |
+
global $wp_version;
|
199 |
+
if ( version_compare( $wp_version, '2.8alpha', '>' ) )
|
200 |
+
add_filter( 'plugin_row_meta', 'crp_plugin_actions', 10, 2 ); // only 2.8 and higher
|
201 |
+
else add_filter( 'plugin_action_links', 'crp_plugin_actions', 10, 2 );
|
202 |
+
|
203 |
|
204 |
?>
|
languages/crp-en_US.mo
ADDED
Binary file
|
languages/crp-en_US.po
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Contextual Related Posts\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2009-08-02 12:12+0530\n"
|
6 |
+
"PO-Revision-Date: \n"
|
7 |
+
"Last-Translator: Ajay D'Souza <me@ajaydsouza.com>\n"
|
8 |
+
"Language-Team: <me@ajaydsouza.com>\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Poedit-Language: English\n"
|
13 |
+
"X-Poedit-KeywordsList: __;_e;_c;__ngettext\n"
|
14 |
+
"X-Poedit-Basepath: ../\n"
|
15 |
+
"X-Poedit-SearchPath-0: .\n"
|
16 |
+
|
17 |
+
#: admin.inc.php:49
|
18 |
+
msgid "Options saved successfully."
|
19 |
+
msgstr ""
|
20 |
+
|
21 |
+
#: admin.inc.php:58
|
22 |
+
msgid "Options set to Default."
|
23 |
+
msgstr ""
|
24 |
+
|
25 |
+
#: admin.inc.php:73
|
26 |
+
msgid "Index recreated"
|
27 |
+
msgstr ""
|
28 |
+
|
29 |
+
#: admin.inc.php:84
|
30 |
+
msgid "Support the Development"
|
31 |
+
msgstr ""
|
32 |
+
|
33 |
+
#: admin.inc.php:88
|
34 |
+
msgid "If you find "
|
35 |
+
msgstr ""
|
36 |
+
|
37 |
+
#: admin.inc.php:90
|
38 |
+
msgid "useful, please do"
|
39 |
+
msgstr ""
|
40 |
+
|
41 |
+
#: admin.inc.php:91
|
42 |
+
msgid "drop in your contribution"
|
43 |
+
msgstr ""
|
44 |
+
|
45 |
+
#: admin.inc.php:92
|
46 |
+
msgid "Some reasons why you should."
|
47 |
+
msgstr ""
|
48 |
+
|
49 |
+
#: admin.inc.php:99
|
50 |
+
msgid "Options:"
|
51 |
+
msgstr ""
|
52 |
+
|
53 |
+
#: admin.inc.php:104
|
54 |
+
msgid "Number of related posts to display: "
|
55 |
+
msgstr ""
|
56 |
+
|
57 |
+
#: admin.inc.php:110
|
58 |
+
msgid "Title of related posts: "
|
59 |
+
msgstr ""
|
60 |
+
|
61 |
+
#: admin.inc.php:114
|
62 |
+
msgid "Exclude Categories: "
|
63 |
+
msgstr ""
|
64 |
+
|
65 |
+
#: admin.inc.php:129
|
66 |
+
msgid "When there are no posts, what should be shown?"
|
67 |
+
msgstr ""
|
68 |
+
|
69 |
+
#: admin.inc.php:132
|
70 |
+
msgid "Blank Output"
|
71 |
+
msgstr ""
|
72 |
+
|
73 |
+
#: admin.inc.php:136
|
74 |
+
msgid "Display \"No Related Posts\""
|
75 |
+
msgstr ""
|
76 |
+
|
77 |
+
#: admin.inc.php:142
|
78 |
+
msgid "Add related posts to the post content on single posts. <br />If you choose to disable this, please add <code><?php if(function_exists('echo_ald_crp')) echo_ald_crp(); ?></code> to your template file where you want it displayed"
|
79 |
+
msgstr ""
|
80 |
+
|
81 |
+
#: admin.inc.php:148
|
82 |
+
msgid "Add related posts to pages. <br />If you choose to disable this, please add <code><?php if(function_exists('echo_ald_crp')) echo_ald_crp(); ?></code> to your template file where you want it displayed"
|
83 |
+
msgstr ""
|
84 |
+
|
85 |
+
#: admin.inc.php:154
|
86 |
+
msgid "Add related posts to feed"
|
87 |
+
msgstr ""
|
88 |
+
|
89 |
+
#: admin.inc.php:160
|
90 |
+
msgid "Find related posts based on content as well as title. If unchecked, only posts titles are used. (I recommend using a caching plugin if you enable this)"
|
91 |
+
msgstr ""
|
92 |
+
|
93 |
+
#: admin.inc.php:166
|
94 |
+
msgid "Exclude Pages in Related Posts"
|
95 |
+
msgstr ""
|
96 |
+
|
97 |
+
#: admin.inc.php:171
|
98 |
+
msgid "Do you want to set options to Default? If you don't have a copy of the username, please hit Cancel and copy it first."
|
99 |
+
msgstr ""
|
100 |
+
|
101 |
+
#: admin.inc.php:172
|
102 |
+
msgid "Are you sure you want to recreate the index?"
|
103 |
+
msgstr ""
|
104 |
+
|
105 |
+
#: admin.inc.php:197
|
106 |
+
msgid "Related Posts"
|
107 |
+
msgstr ""
|
108 |
+
|
109 |
+
#: contextual-related-posts.php:89
|
110 |
+
#: contextual-related-posts.php:93
|
111 |
+
msgid "No related posts found"
|
112 |
+
msgstr ""
|
113 |
+
|
114 |
+
#: contextual-related-posts.php:125
|
115 |
+
msgid "<h3>Related Posts:</h3>"
|
116 |
+
msgstr ""
|
117 |
+
|
118 |
+
#: contextual-related-posts.php:192
|
119 |
+
msgid "Settings"
|
120 |
+
msgstr ""
|
121 |
+
|
122 |
+
#: contextual-related-posts.php:193
|
123 |
+
msgid "Support"
|
124 |
+
msgstr ""
|
125 |
+
|
126 |
+
#: contextual-related-posts.php:194
|
127 |
+
msgid "Donate"
|
128 |
+
msgstr ""
|
129 |
+
|
languages/crp-en_US.pot
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Contextual Related Posts\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2009-08-02 12:12+0530\n"
|
6 |
+
"PO-Revision-Date: \n"
|
7 |
+
"Last-Translator: Ajay D'Souza <me@ajaydsouza.com>\n"
|
8 |
+
"Language-Team: <me@ajaydsouza.com>\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Poedit-Language: English\n"
|
13 |
+
"X-Poedit-KeywordsList: __;_e;_c;__ngettext\n"
|
14 |
+
"X-Poedit-Basepath: ../\n"
|
15 |
+
"X-Poedit-SearchPath-0: .\n"
|
16 |
+
|
17 |
+
#: admin.inc.php:49
|
18 |
+
msgid "Options saved successfully."
|
19 |
+
msgstr ""
|
20 |
+
|
21 |
+
#: admin.inc.php:58
|
22 |
+
msgid "Options set to Default."
|
23 |
+
msgstr ""
|
24 |
+
|
25 |
+
#: admin.inc.php:73
|
26 |
+
msgid "Index recreated"
|
27 |
+
msgstr ""
|
28 |
+
|
29 |
+
#: admin.inc.php:84
|
30 |
+
msgid "Support the Development"
|
31 |
+
msgstr ""
|
32 |
+
|
33 |
+
#: admin.inc.php:88
|
34 |
+
msgid "If you find "
|
35 |
+
msgstr ""
|
36 |
+
|
37 |
+
#: admin.inc.php:90
|
38 |
+
msgid "useful, please do"
|
39 |
+
msgstr ""
|
40 |
+
|
41 |
+
#: admin.inc.php:91
|
42 |
+
msgid "drop in your contribution"
|
43 |
+
msgstr ""
|
44 |
+
|
45 |
+
#: admin.inc.php:92
|
46 |
+
msgid "Some reasons why you should."
|
47 |
+
msgstr ""
|
48 |
+
|
49 |
+
#: admin.inc.php:99
|
50 |
+
msgid "Options:"
|
51 |
+
msgstr ""
|
52 |
+
|
53 |
+
#: admin.inc.php:104
|
54 |
+
msgid "Number of related posts to display: "
|
55 |
+
msgstr ""
|
56 |
+
|
57 |
+
#: admin.inc.php:110
|
58 |
+
msgid "Title of related posts: "
|
59 |
+
msgstr ""
|
60 |
+
|
61 |
+
#: admin.inc.php:114
|
62 |
+
msgid "Exclude Categories: "
|
63 |
+
msgstr ""
|
64 |
+
|
65 |
+
#: admin.inc.php:129
|
66 |
+
msgid "When there are no posts, what should be shown?"
|
67 |
+
msgstr ""
|
68 |
+
|
69 |
+
#: admin.inc.php:132
|
70 |
+
msgid "Blank Output"
|
71 |
+
msgstr ""
|
72 |
+
|
73 |
+
#: admin.inc.php:136
|
74 |
+
msgid "Display \"No Related Posts\""
|
75 |
+
msgstr ""
|
76 |
+
|
77 |
+
#: admin.inc.php:142
|
78 |
+
msgid "Add related posts to the post content on single posts. <br />If you choose to disable this, please add <code><?php if(function_exists('echo_ald_crp')) echo_ald_crp(); ?></code> to your template file where you want it displayed"
|
79 |
+
msgstr ""
|
80 |
+
|
81 |
+
#: admin.inc.php:148
|
82 |
+
msgid "Add related posts to pages. <br />If you choose to disable this, please add <code><?php if(function_exists('echo_ald_crp')) echo_ald_crp(); ?></code> to your template file where you want it displayed"
|
83 |
+
msgstr ""
|
84 |
+
|
85 |
+
#: admin.inc.php:154
|
86 |
+
msgid "Add related posts to feed"
|
87 |
+
msgstr ""
|
88 |
+
|
89 |
+
#: admin.inc.php:160
|
90 |
+
msgid "Find related posts based on content as well as title. If unchecked, only posts titles are used. (I recommend using a caching plugin if you enable this)"
|
91 |
+
msgstr ""
|
92 |
+
|
93 |
+
#: admin.inc.php:166
|
94 |
+
msgid "Exclude Pages in Related Posts"
|
95 |
+
msgstr ""
|
96 |
+
|
97 |
+
#: admin.inc.php:171
|
98 |
+
msgid "Do you want to set options to Default? If you don't have a copy of the username, please hit Cancel and copy it first."
|
99 |
+
msgstr ""
|
100 |
+
|
101 |
+
#: admin.inc.php:172
|
102 |
+
msgid "Are you sure you want to recreate the index?"
|
103 |
+
msgstr ""
|
104 |
+
|
105 |
+
#: admin.inc.php:197
|
106 |
+
msgid "Related Posts"
|
107 |
+
msgstr ""
|
108 |
+
|
109 |
+
#: contextual-related-posts.php:89
|
110 |
+
#: contextual-related-posts.php:93
|
111 |
+
msgid "No related posts found"
|
112 |
+
msgstr ""
|
113 |
+
|
114 |
+
#: contextual-related-posts.php:125
|
115 |
+
msgid "<h3>Related Posts:</h3>"
|
116 |
+
msgstr ""
|
117 |
+
|
118 |
+
#: contextual-related-posts.php:192
|
119 |
+
msgid "Settings"
|
120 |
+
msgstr ""
|
121 |
+
|
122 |
+
#: contextual-related-posts.php:193
|
123 |
+
msgid "Support"
|
124 |
+
msgstr ""
|
125 |
+
|
126 |
+
#: contextual-related-posts.php:194
|
127 |
+
msgid "Donate"
|
128 |
+
msgstr ""
|
129 |
+
|
readme.txt
CHANGED
@@ -4,12 +4,11 @@ Contributors: Ajay, Mark Ghosh
|
|
4 |
Donate link: http://ajaydsouza.com/donate/
|
5 |
Stable tag: trunk
|
6 |
Requires at least: 2.5
|
7 |
-
Tested up to: 2.
|
8 |
|
9 |
|
10 |
Show user defined number of contextually related posts
|
11 |
|
12 |
-
|
13 |
== Description ==
|
14 |
|
15 |
Display a list of contextually related posts for the current post.
|
@@ -22,7 +21,7 @@ Now, you can choose to exclude posts from certain categories as well as exclude
|
|
22 |
= Features =
|
23 |
|
24 |
* Display Related Posts automatically in content / feed, no need to edit template files
|
25 |
-
* Doesn
|
26 |
* You can manually add code to your template where you want the related posts to be displayed
|
27 |
* Exclude posts from categories
|
28 |
* Exclude display of related posts on Pages
|
@@ -30,23 +29,40 @@ Now, you can choose to exclude posts from certain categories as well as exclude
|
|
30 |
* Find related posts based on content and post title
|
31 |
|
32 |
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
-
|
36 |
-
*
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
*
|
41 |
-
*
|
42 |
-
*
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
*
|
49 |
-
|
|
|
|
|
50 |
|
51 |
|
52 |
== Installation ==
|
@@ -60,7 +76,6 @@ Now, you can choose to exclude posts from certain categories as well as exclude
|
|
60 |
4. Goto Settings > Related Posts to configure
|
61 |
|
62 |
|
63 |
-
|
64 |
== Frequently Asked Questions ==
|
65 |
|
66 |
= What are the requirements for this plugin? =
|
4 |
Donate link: http://ajaydsouza.com/donate/
|
5 |
Stable tag: trunk
|
6 |
Requires at least: 2.5
|
7 |
+
Tested up to: 2.8.2
|
8 |
|
9 |
|
10 |
Show user defined number of contextually related posts
|
11 |
|
|
|
12 |
== Description ==
|
13 |
|
14 |
Display a list of contextually related posts for the current post.
|
21 |
= Features =
|
22 |
|
23 |
* Display Related Posts automatically in content / feed, no need to edit template files
|
24 |
+
* Doesn't require the post to be tagged in order to display related posts
|
25 |
* You can manually add code to your template where you want the related posts to be displayed
|
26 |
* Exclude posts from categories
|
27 |
* Exclude display of related posts on Pages
|
29 |
* Find related posts based on content and post title
|
30 |
|
31 |
|
32 |
+
== Changelog ==
|
33 |
+
|
34 |
+
= 1.4 =
|
35 |
+
* Added complete localization support
|
36 |
+
* Added button to recreate the mySQL FULLTEXT index
|
37 |
+
|
38 |
+
= 1.3.1 =
|
39 |
+
* Fixed bug that didn't blank out posts even when option was selected
|
40 |
+
|
41 |
+
= 1.3 =
|
42 |
+
* Better optimization in WP-Admin area.
|
43 |
+
* Fixed compatibility problems with Simple Tags plugin
|
44 |
+
* Fixed large number of queries being generated
|
45 |
+
|
46 |
+
= 1.2.2 =
|
47 |
+
* Minor bug fixed about limit of posts
|
48 |
|
49 |
+
= 1.2.1 =
|
50 |
+
* Bug fixed to support PHP4
|
51 |
+
|
52 |
+
= 1.2 =
|
53 |
+
* Option to blank output in case nothing is found
|
54 |
+
* Exclude posts from certain categories
|
55 |
+
* Exclude pages
|
56 |
+
* Option to choose if you want related posts to be displayed on pages
|
57 |
+
|
58 |
+
= 1.1.1 =
|
59 |
+
* Now you can optionally choose if you want to use the post content to search for related posts
|
60 |
+
|
61 |
+
= 1.1 =
|
62 |
+
* Fixed MySQL index key conflicts by using a more unique index key name.
|
63 |
+
|
64 |
+
= 1.0.1 =
|
65 |
+
* Release
|
66 |
|
67 |
|
68 |
== Installation ==
|
76 |
4. Goto Settings > Related Posts to configure
|
77 |
|
78 |
|
|
|
79 |
== Frequently Asked Questions ==
|
80 |
|
81 |
= What are the requirements for this plugin? =
|
uninstall.php
CHANGED
@@ -7,5 +7,12 @@ if ( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') ) {
|
|
7 |
|
8 |
$sql = "ALTER TABLE $poststable DROP INDEX crp_related";
|
9 |
$wpdb->query($sql);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
delete_option('ald_crp_settings');
|
11 |
?>
|
7 |
|
8 |
$sql = "ALTER TABLE $poststable DROP INDEX crp_related";
|
9 |
$wpdb->query($sql);
|
10 |
+
|
11 |
+
$sql = "ALTER TABLE $poststable DROP INDEX crp_related_title";
|
12 |
+
$wpdb->query($sql);
|
13 |
+
|
14 |
+
$sql = "ALTER TABLE $poststable DROP INDEX crp_related_content";
|
15 |
+
$wpdb->query($sql);
|
16 |
+
|
17 |
delete_option('ald_crp_settings');
|
18 |
?>
|