Version Description
Download this release
Release Info
Developer | hchouhan |
Plugin | I Recommend This |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- css/add.png +0 -0
- css/heart.png +0 -0
- css/i-recommend-this.css +32 -0
- i-i-recommend-this-this.php +289 -0
- js/i-recommend-this.js +11 -0
- readme.txt +39 -0
- recommend.php +25 -0
css/add.png
ADDED
Binary file
|
css/heart.png
ADDED
Binary file
|
css/i-recommend-this.css
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.iRecommendThis { display:block; clear:both; position:relative; }
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
.iRecommendThis a { background:url(heart.png) top left no-repeat; padding:0 0 0 20px; cursor:pointer !important; }
|
6 |
+
.iRecommendThis a.active, .iRecommendThis a:hover { background-position:0 -19px; color: #F56559 !important; }
|
7 |
+
.iRecommendThis span.counter {padding:0; margin:0; font-weight:bold; display:inline !important; }
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
/*
|
13 |
+
.iRecommendThis .image { background:url(heart.png) top left no-repeat; float:left; height:16px; width:16px; background-position:0 3px ; padding:0 0 0 4px; }
|
14 |
+
.iRecommendThis .counter { background:url(heart.png) top left no-repeat; background-position:0 3px ; padding:0 0 0 20px; font-weight:bold; }
|
15 |
+
.iRecommendThis .counter a.image { background:url(add.png) center right no-repeat; padding:0 20px 0 0; }
|
16 |
+
|
17 |
+
|
18 |
+
.iRecommendThis { display:block; }
|
19 |
+
.iRecommendThis a { background:url(heart.png) top left no-repeat; padding:0 0 0 20px; cursor:pointer !important; }
|
20 |
+
.iRecommendThis a.active, .iRecommendThis a:hover { background-position:0 -19px; color: #F56559 !important; }
|
21 |
+
|
22 |
+
|
23 |
+
.iRecommendThis { display:inline; }
|
24 |
+
.iRecommendThis .counter {padding:0 0 0 0; font-weight:bold; margin-right:5px; }
|
25 |
+
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
.iRecommendThis .counter { background:url(heart.png) center left no-repeat; padding:0 0 0 20px; font-weight:bold; margin-left:5px; }
|
30 |
+
.iRecommendThis .counter a.image { background:url(add.png) center right no-repeat; padding:0 20px 0 0; }
|
31 |
+
|
32 |
+
*/
|
i-i-recommend-this-this.php
ADDED
@@ -0,0 +1,289 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: I Recommend This
|
4 |
+
Plugin URI: http://www.harishchouhan.com/personal-projects/i-recommend-this/
|
5 |
+
Description: This plugin allows your visitors to simply recommend or like your posts instead of commment it.
|
6 |
+
Version: 1.0
|
7 |
+
Author: Harish Chouhan
|
8 |
+
Author URI: http://www.harishchouhan.com
|
9 |
+
|
10 |
+
Copyright 2012 Harish Chouhan (email : me@harishchouhan.com)
|
11 |
+
|
12 |
+
This program is free software; you can redistribute it and/or modify
|
13 |
+
it under the terms of the GNU General Public License as published by
|
14 |
+
the Free Software Foundation; either version 2 of the License, or
|
15 |
+
(at your option) any later version.
|
16 |
+
|
17 |
+
This program is distributed in the hope that it will be useful,
|
18 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
+
GNU General Public License for more details.
|
21 |
+
*/
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
#### INSTALL PROCESS ####
|
26 |
+
$ilt_dbVersion = "1.0";
|
27 |
+
|
28 |
+
function setOptionsIRT() {
|
29 |
+
global $wpdb;
|
30 |
+
global $irt_dbVersion;
|
31 |
+
|
32 |
+
$table_name = $wpdb->prefix . "irecommendthis_votes";
|
33 |
+
if($wpdb->get_var("show tables recommend '$table_name'") != $table_name) {
|
34 |
+
$sql = "CREATE TABLE " . $table_name . " (
|
35 |
+
id MEDIUMINT(9) NOT NULL AUTO_INCREMENT,
|
36 |
+
time TIMESTAMP NOT NULL,
|
37 |
+
post_id BIGINT(20) NOT NULL,
|
38 |
+
ip VARCHAR(15) NOT NULL,
|
39 |
+
UNIQUE KEY id (id)
|
40 |
+
);";
|
41 |
+
|
42 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
43 |
+
dbDelta($sql);
|
44 |
+
|
45 |
+
add_option("irt_dbVersion", $irt_dbVersion);
|
46 |
+
}
|
47 |
+
|
48 |
+
add_option('irt_jquery', '1', '', 'yes');
|
49 |
+
add_option('irt_onPage', '1', '', 'yes');
|
50 |
+
add_option('irt_textOrImage', 'image', '', 'yes');
|
51 |
+
add_option('irt_text', 'I recommend This', '', 'yes');
|
52 |
+
}
|
53 |
+
|
54 |
+
register_activation_hook(__FILE__, 'setOptionsIRT');
|
55 |
+
|
56 |
+
function unsetOptionsIRT() {
|
57 |
+
global $wpdb;
|
58 |
+
$wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."irecommendthis_votes");
|
59 |
+
|
60 |
+
delete_option('irt_jquery');
|
61 |
+
delete_option('irt_onPage');
|
62 |
+
delete_option('irt_textOrImage');
|
63 |
+
delete_option('irt_text');
|
64 |
+
delete_option('most_recommended_posts');
|
65 |
+
delete_option('irt_dbVersion');
|
66 |
+
}
|
67 |
+
|
68 |
+
register_uninstall_hook(__FILE__, 'unsetOptionsIRT');
|
69 |
+
####
|
70 |
+
|
71 |
+
|
72 |
+
#### ADMIN OPTIONS ####
|
73 |
+
function IRecommendThisAdminMenu() {
|
74 |
+
add_options_page('I Recommend This', 'I Recommend This', '10', 'IRecommendThisAdminMenu', 'IRecommendThisAdminContent');
|
75 |
+
}
|
76 |
+
add_action('admin_menu', 'IRecommendThisAdminMenu');
|
77 |
+
|
78 |
+
function IRecommendThisAdminRegisterSettings() { // whitelist options
|
79 |
+
register_setting( 'irt_options', 'irt_jquery' );
|
80 |
+
register_setting( 'irt_options', 'irt_onPage' );
|
81 |
+
register_setting( 'irt_options', 'irt_textOrImage' );
|
82 |
+
register_setting( 'irt_options', 'irt_text' );
|
83 |
+
}
|
84 |
+
add_action('admin_init', 'IRecommendThisAdminRegisterSettings');
|
85 |
+
|
86 |
+
function IRecommendThisAdminContent() {
|
87 |
+
?>
|
88 |
+
<div class="wrap">
|
89 |
+
<h2>"I Recommend This" Options</h2>
|
90 |
+
<br class="clear" />
|
91 |
+
|
92 |
+
<div id="poststuff" class="ui-sortable meta-box-sortables">
|
93 |
+
<div id="irecommendthisoptions" class="postbox">
|
94 |
+
<h3><?php _e('Configuration'); ?></h3>
|
95 |
+
<div class="inside">
|
96 |
+
<form method="post" action="options.php">
|
97 |
+
<?php settings_fields('irt_options'); ?>
|
98 |
+
<table class="form-table">
|
99 |
+
<tr valign="top">
|
100 |
+
<th scope="row"><label for="irt_jquery"><?php _e('jQuery framework', 'i-recommend-this'); ?></label></th>
|
101 |
+
<td>
|
102 |
+
<select name="irt_jquery" id="irt_jquery">
|
103 |
+
<?php echo get_option('irt_jquery') == '1' ? '<option value="1" selected="selected">'.__('Enabled', 'i-recommend-this').'</option><option value="0">'.__('Disabled', 'i-recommend-this').'</option>' : '<option value="1">'.__('Enabled', 'i-recommend-this').'</option><option value="0" selected="selected">'.__('Disabled', 'i-recommend-this').'</option>'; ?>
|
104 |
+
</select>
|
105 |
+
<span class="description"><?php _e('Disable it if you already have the jQuery framework enabled in your theme.', 'i-recommend-this'); ?></span>
|
106 |
+
</td>
|
107 |
+
</tr>
|
108 |
+
<tr valign="top">
|
109 |
+
<th scope="row"><legend><?php _e('Image or text?', 'i-recommend-this'); ?></legend></th>
|
110 |
+
<td>
|
111 |
+
<label for="irt_textOrImage" style="padding:3px 20px 3px 0; margin-right:20px; background: url(<?php echo WP_PLUGIN_URL.'/i-recommend-this/css/add.png'; ?>) no-repeat right center;">
|
112 |
+
<?php echo get_option('irt_textOrImage') == 'image' ? '<input type="radio" name="irt_textOrImage" id="irt_textOrImage" value="image" checked="checked">' : '<input type="radio" name="irt_textOrImage" id="irt_textOrImage" value="image">'; ?>
|
113 |
+
</label>
|
114 |
+
<label for="irt_text">
|
115 |
+
<?php echo get_option('irt_textOrImage') == 'text' ? '<input type="radio" name="irt_textOrImage" id="irt_textOrImage" value="text" checked="checked">' : '<input type="radio" name="irt_textOrImage" id="irt_textOrImage" value="text">'; ?>
|
116 |
+
<input type="text" name="irt_text" id="irt_text" value="<?php echo get_option('irt_text'); ?>" />
|
117 |
+
</label>
|
118 |
+
</td>
|
119 |
+
</tr>
|
120 |
+
<tr valign="top">
|
121 |
+
<th scope="row"><legend><?php _e('Automatic display', 'i-recommend-this'); ?></legend></th>
|
122 |
+
<td>
|
123 |
+
<label for="irt_onPage">
|
124 |
+
<?php echo get_option('irt_onPage') == '1' ? '<input type="checkbox" name="irt_onPage" id="ilt_onPage" value="1" checked="checked">' : '<input type="checkbox" name="irt_onPage" id="irt_onPage" value="1">'; ?>
|
125 |
+
<?php _e('<strong>On all posts</strong> (home, archives, search) at the bottom of the post', 'i-recommend-this'); ?>
|
126 |
+
</label>
|
127 |
+
<p class="description"><?php _e('If you disable this option, you have to put manually the code', 'i-recommend-this'); ?><code><?php if(function_exists(getIRecommendThis)) getIRecommendThis('get'); ?></code> <?php _e('wherever you want in your template.', 'i-recommend-this'); ?></p>
|
128 |
+
</td>
|
129 |
+
</tr>
|
130 |
+
<tr valign="top">
|
131 |
+
<th scope="row"><input class="button-primary" type="submit" name="Save" value="<?php _e('Save Options', 'i-recommend-this'); ?>" /></th>
|
132 |
+
<td></td>
|
133 |
+
</tr>
|
134 |
+
</table>
|
135 |
+
</form>
|
136 |
+
</div>
|
137 |
+
</div>
|
138 |
+
</div>
|
139 |
+
</div>
|
140 |
+
<?php
|
141 |
+
}
|
142 |
+
####
|
143 |
+
|
144 |
+
|
145 |
+
#### WIDGET ####
|
146 |
+
function most_recommended_posts($numberOf, $before, $after, $show_count) {
|
147 |
+
global $wpdb;
|
148 |
+
|
149 |
+
$request = "SELECT ID, post_title, meta_value FROM $wpdb->posts, $wpdb->postmeta";
|
150 |
+
$request .= " WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id";
|
151 |
+
$request .= " AND post_status='publish' AND post_type='post' AND meta_key='_recommended'";
|
152 |
+
$request .= " ORDER BY $wpdb->postmeta.meta_value+0 DESC LIMIT $numberOf";
|
153 |
+
$posts = $wpdb->get_results($request);
|
154 |
+
|
155 |
+
foreach ($posts as $post) {
|
156 |
+
$post_title = stripslashes($post->post_title);
|
157 |
+
$permalink = get_permalink($post->ID);
|
158 |
+
$post_count = $post->meta_value;
|
159 |
+
|
160 |
+
echo $before.'<a href="' . $permalink . '" title="' . $post_title.'" rel="nofollow">' . $post_title . '</a>';
|
161 |
+
echo $show_count == '1' ? ' ('.$post_count.')' : '';
|
162 |
+
echo $after;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
function add_widget_most_recommended_posts() {
|
167 |
+
function widget_most_recommended_posts($args) {
|
168 |
+
extract($args);
|
169 |
+
$options = get_option("most_recommended_posts");
|
170 |
+
if (!is_array( $options )) {
|
171 |
+
$options = array(
|
172 |
+
'title' => 'Most recommended posts',
|
173 |
+
'number' => '5',
|
174 |
+
'show_count' => '0'
|
175 |
+
);
|
176 |
+
}
|
177 |
+
$title = $options['title'];
|
178 |
+
$numberOf = $options['number'];
|
179 |
+
$show_count = $options['show_count'];
|
180 |
+
|
181 |
+
echo $before_widget;
|
182 |
+
echo $before_title . $title . $after_title;
|
183 |
+
echo '<ul class="mostrecommendedposts">';
|
184 |
+
|
185 |
+
most_recommended_posts($numberOf, '<li>', '</li>', $show_count);
|
186 |
+
|
187 |
+
echo '</ul>';
|
188 |
+
echo $after_widget;
|
189 |
+
}
|
190 |
+
register_sidebar_widget('Most recommended posts', 'widget_most_recommended_posts');
|
191 |
+
|
192 |
+
function options_widget_most_recommended_posts() {
|
193 |
+
$options = get_option("most_recommended_posts");
|
194 |
+
|
195 |
+
if (!is_array( $options )) {
|
196 |
+
$options = array(
|
197 |
+
'title' => 'Most recommended posts',
|
198 |
+
'number' => '5',
|
199 |
+
'show_count' => '0'
|
200 |
+
);
|
201 |
+
}
|
202 |
+
|
203 |
+
if ($_POST['mrp-submit']) {
|
204 |
+
$options['title'] = htmlspecialchars($_POST['mrp-title']);
|
205 |
+
$options['number'] = htmlspecialchars($_POST['mrp-number']);
|
206 |
+
$options['show_count'] = $_POST['mrp-show-count'];
|
207 |
+
if ( $options['number'] > 15) { $options['number'] = 15; }
|
208 |
+
|
209 |
+
update_option("most_recommended_posts", $options);
|
210 |
+
}
|
211 |
+
?>
|
212 |
+
<p><label for="mrp-title"><?php _e('Title:', 'i-recommend-this'); ?><br />
|
213 |
+
<input class="widefat" type="text" id="mrp-title" name="mrp-title" value="<?php echo $options['title'];?>" /></label></p>
|
214 |
+
|
215 |
+
<p><label for="mrp-number"><?php _e('Number of posts to show:', 'i-recommend-this'); ?><br />
|
216 |
+
<input type="text" id="mrp-number" name="mrp-number" style="width: 25px;" value="<?php echo $options['number'];?>" /> <small>(max. 15)</small></label></p>
|
217 |
+
|
218 |
+
<p><label for="mrp-show-count"><input type="checkbox" id="mrp-show-count" name="mrp-show-count" value="1"<?php if($options['show_count'] == '1') echo 'checked="checked"'; ?> /> <?php _e('Show post count', 'i-recommend-this'); ?></label></p>
|
219 |
+
|
220 |
+
<input type="hidden" id="mrp-submit" name="mrp-submit" value="1" />
|
221 |
+
<?php
|
222 |
+
}
|
223 |
+
register_widget_control('Most recommended posts', 'options_widget_most_recommended_posts');
|
224 |
+
}
|
225 |
+
|
226 |
+
add_action('init', 'add_widget_most_recommended_posts');
|
227 |
+
####
|
228 |
+
|
229 |
+
|
230 |
+
#### FRONT-END VIEW ####
|
231 |
+
function getIRecommendThis($arg) {
|
232 |
+
global $wpdb;
|
233 |
+
$post_ID = get_the_ID();
|
234 |
+
$ip = $_SERVER['REMOTE_ADDR'];
|
235 |
+
|
236 |
+
$recommended = get_post_meta($post_ID, '_recommended', true) != '' ? get_post_meta($post_ID, '_recommended', true) : '0';
|
237 |
+
$voteStatusByIp = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."irecommendthis_votes WHERE post_id = '$post_ID' AND ip = '$ip'");
|
238 |
+
|
239 |
+
if (!isset($_COOKIE['recommended-'.$post_ID]) && $voteStatusByIp == 0) {
|
240 |
+
//$counter = '<a onclick="likeThis('.$post_ID.');">'.$liked.'';
|
241 |
+
//$counter = '<a onclick="likeThis('.$post_ID.');" class"image">'.$liked.'</a>';
|
242 |
+
$counter = $recommended;
|
243 |
+
$recommend_status = "";
|
244 |
+
}
|
245 |
+
else {
|
246 |
+
$counter = $recommended;
|
247 |
+
$recommend_status = "active";
|
248 |
+
}
|
249 |
+
|
250 |
+
$iRecommendThis = '<div id="iRecommendThis-'.$post_ID.'" class="iRecommendThis"><a onclick="recommendThis('.$post_ID.');" class="'.$recommend_status.'">';
|
251 |
+
$iRecommendThis .= '<span class="counter">'.$counter.'</span>';
|
252 |
+
$iRecommendThis .= '</a></div>';
|
253 |
+
|
254 |
+
if ($arg == 'put') {
|
255 |
+
return $iRecommendThis;
|
256 |
+
}
|
257 |
+
else {
|
258 |
+
echo $iRecommendThis;
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
if (get_option('irt_onPage') == '1') {
|
263 |
+
function putIRecommendThis($content) {
|
264 |
+
if(!is_feed() && !is_page()) {
|
265 |
+
$content.= getIRecommendThis('put');
|
266 |
+
}
|
267 |
+
return $content;
|
268 |
+
}
|
269 |
+
|
270 |
+
add_filter('the_content', putIRecommendThis);
|
271 |
+
}
|
272 |
+
|
273 |
+
function enqueueScripts() {
|
274 |
+
if (get_option('irt_jquery') == '1') {
|
275 |
+
wp_enqueue_script('iRecommendThis', WP_PLUGIN_URL.'/i-recommend-this/js/i-recommend-this.js', array('jquery'));
|
276 |
+
}
|
277 |
+
else {
|
278 |
+
wp_enqueue_script('iRecommendThis', WP_PLUGIN_URL.'/i-recommend-this/js/i-recommend-this.js');
|
279 |
+
}
|
280 |
+
}
|
281 |
+
|
282 |
+
function addHeaderLinks() {
|
283 |
+
echo '<link rel="stylesheet" type="text/css" href="'.WP_PLUGIN_URL.'/i-recommend-this/css/i-recommend-this.css" media="screen" />'."\n";
|
284 |
+
echo '<script type="text/javascript">var blogUrl = \''.get_bloginfo('wpurl').'\'</script>'."\n";
|
285 |
+
}
|
286 |
+
|
287 |
+
add_action('init', enqueueScripts);
|
288 |
+
add_action('wp_head', addHeaderLinks);
|
289 |
+
?>
|
js/i-recommend-this.js
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function recommendThis(postId) {
|
2 |
+
if (postId != '') {
|
3 |
+
|
4 |
+
jQuery.post(blogUrl + "/wp-content/plugins/i-recommend-this/recommend.php",
|
5 |
+
{ id: postId },
|
6 |
+
function(data){
|
7 |
+
jQuery('#iRecommendThis-'+postId+' a').addClass('active');
|
8 |
+
jQuery('#iRecommendThis-'+postId+' .counter').text(data);
|
9 |
+
});
|
10 |
+
}
|
11 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: Harish Chouhan, Benoit "LeBen" Burgener
|
3 |
+
Donate link:
|
4 |
+
Tags: recommend, like, love, post, rate, rating, heart
|
5 |
+
Requires at least: 2.5
|
6 |
+
Tested up to: 3.2.2
|
7 |
+
Stable tag: 1
|
8 |
+
|
9 |
+
== Description ==
|
10 |
+
|
11 |
+
This plugin allows your visitors to simply like/recommend your posts instead of comment it.
|
12 |
+
|
13 |
+
This plugin is based on Benoit "LeBen" Burgener "I Like This" Plugin and has been modified after getting requests for the changes I had made on my website.
|
14 |
+
|
15 |
+
= This plugin include =
|
16 |
+
* A counter/button to display the number of "like" and to vote.
|
17 |
+
* A widget and a function to display the X most liked posts.
|
18 |
+
* A preference pane with some options.
|
19 |
+
|
20 |
+
|
21 |
+
== Installation ==
|
22 |
+
|
23 |
+
1. Upload the directory `/i-recommend-this/` to the `/wp-content/plugins/` directory
|
24 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
25 |
+
|
26 |
+
== Frequently Asked Questions ==
|
27 |
+
|
28 |
+
Take a look at the [official "I Recommend This" FAQ](http://www.harishchouhan.com/personal-projects/i-recommend-this/).
|
29 |
+
|
30 |
+
You can also visit the [support center](http://www.harishchouhan.com/personal-projects/i-recommend-this/) and start a discussion if needed.
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
== Changelog ==
|
35 |
+
|
36 |
+
= 1.0
|
37 |
+
* Removed JQuery loading style when heart is clicked.
|
38 |
+
* Modified CSS & Images of LeBen's "I Like This" plugin based on what many users requested.
|
39 |
+
* This is the first version
|
recommend.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once '../../../wp-config.php';
|
3 |
+
|
4 |
+
global $wpdb;
|
5 |
+
$post_ID = $_POST['id'];
|
6 |
+
$ip = $_SERVER['REMOTE_ADDR'];
|
7 |
+
$recommend = get_post_meta($post_ID, '_recommended', true);
|
8 |
+
|
9 |
+
if($post_ID != '') {
|
10 |
+
$voteStatusByIp = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."irecommendthis_votes WHERE post_id = '$post_ID' AND ip = '$ip'");
|
11 |
+
|
12 |
+
if (!isset($_COOKIE['recommended-'.$post_ID]) && $voteStatusByIp == 0) {
|
13 |
+
$recommendNew = $recommend + 1;
|
14 |
+
update_post_meta($post_ID, '_recommended', $recommendNew);
|
15 |
+
|
16 |
+
setcookie('liked-'.$post_ID, time(), time()+3600*24*365, '/');
|
17 |
+
$wpdb->query("INSERT INTO ".$wpdb->prefix."irecommendthis_votes VALUES ('0', NOW(), '$post_ID', '$ip')");
|
18 |
+
|
19 |
+
echo $recommendNew;
|
20 |
+
}
|
21 |
+
else {
|
22 |
+
echo $recommend;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
?>
|