Version Description
- updated : settings page panel for ads
- updated : compatibility setting
Download this release
Release Info
Developer | commentluv |
Plugin | CommentLuv |
Version | 2.92.9 |
Comparing to | |
See all releases |
Code changes from version 2.92.8 to 2.92.9
- commentluv.php +1391 -1371
- readme.txt +9 -4
commentluv.php
CHANGED
@@ -1,1408 +1,1408 @@
|
|
1 |
<?php /* commentluv
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
}
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
if(is_user_logged_in()){
|
133 |
-
global $userdata;
|
134 |
-
get_currentuserinfo();
|
135 |
-
$author = $userdata->display_name;
|
136 |
-
$userid = $userdata->ID;
|
137 |
-
$url = $userdata->user_url;
|
138 |
-
if(!strstr($url,'http://') && $url != ''){
|
139 |
-
$url = 'http://'.$url;
|
140 |
-
}
|
141 |
-
// check for s2 member pluin, add url from it's custom registration fields
|
142 |
-
if(defined('WS_PLUGIN__S2MEMBER_VERSION') && isset($userdata->wp_s2member_custom_fields['website'])){
|
143 |
-
$url = $userdata->wp_s2member_custom_fields['website'];
|
144 |
-
}
|
145 |
-
// check for multisite
|
146 |
-
if(is_multisite()){
|
147 |
-
if(!$url || $url == 'http://'){
|
148 |
-
$userbloginfo = get_blogs_of_user($userid,1);
|
149 |
-
$url = $userbloginfo[1] -> siteurl;
|
150 |
-
}
|
151 |
-
}
|
152 |
-
// final check of url
|
153 |
-
if($url == 'http://'){
|
154 |
-
$url = '';
|
155 |
-
}
|
156 |
-
// spit out hidden fields
|
157 |
-
echo '<input type="hidden" id="'.$author_name.'" name="'.$author_name.'" value="'.$author.'"/>';
|
158 |
-
// if buddypress, don't hide field
|
159 |
-
if(function_exists('bp_core_setup_globals')){
|
160 |
-
$input_type = 'text';
|
161 |
-
} else {
|
162 |
-
$input_type = 'hidden';
|
163 |
}
|
164 |
-
echo '<input type="'.$input_type.'" id="'.$url_name.'" name="'.$url_name.'" value="'.$url.'"/>';
|
165 |
-
}
|
166 |
-
// add hidden fields for holding information about type,choice,html and request for every user
|
167 |
-
echo '<input type="hidden" name="cl_post_title" id="cl_post_title"/>';
|
168 |
-
echo '<input type="hidden" name="cl_post_url" id="cl_post_url"/>';
|
169 |
-
echo '<input type="hidden" name="cl_prem" id="cl_prem"/>';
|
170 |
-
// show badge (unless user set to manual insert)
|
171 |
-
if(($clbadgeshown == false && !isset($options['template_insert'])) || (isset($options['template_insert']) && $options['template_insert'] == '') ){
|
172 |
-
$this->display_badge();
|
173 |
}
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
extract($this->get_options());
|
178 |
-
if($minifying != 'on' || !$this->is_enabled()){
|
179 |
-
return;
|
180 |
}
|
181 |
-
//
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
}
|
189 |
-
$data .= implode(",",$arr); $data .= "};";
|
190 |
-
echo "<script type='text/javascript'>\n";
|
191 |
-
echo "/* <![CDATA[ */\n";
|
192 |
-
echo $data;
|
193 |
-
echo "\n/* ]]> */\n";
|
194 |
-
echo "</script>\n";
|
195 |
}
|
|
|
196 |
}
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
'
|
242 |
-
'no_url_message'=>__('Please enter a URL and then click the CommentLuv checkbox if you want to add your last blog post',$this->plugin_domain),
|
243 |
-
'no_http_message'=>__('Please use http:// in front of your url',$this->plugin_domain),
|
244 |
-
'no_url_logged_in_message'=>__('You need to visit your profile in the dashboard and update your details with your site URL',$this->plugin_domain),
|
245 |
-
'no_info_message'=>__('No info was available or an error occured',$this->plugin_domain));
|
246 |
-
if($minifying != 'on'){
|
247 |
-
wp_localize_script('commentluv_script','cl_settings',$this->localize);
|
248 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
|
250 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
}
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
*/
|
285 |
-
function admin_init(){
|
286 |
-
// whitelist options
|
287 |
-
register_setting( 'commentluv_options_group', $this->db_option ,array(&$this,'options_sanitize' ) );
|
288 |
-
$options = $this->get_options();
|
289 |
-
//if(isset($options['upgrade'])){
|
290 |
-
if(isset($options['upgrade']) && version_compare($options['upgrade'],$this->php_version($this->version),'>')){
|
291 |
-
add_action('admin_notices',array(&$this,'show_upgrade_notice'));
|
292 |
-
}
|
293 |
}
|
|
|
294 |
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
}
|
306 |
-
$menutitle = '<img src="' . $this->plugin_url . 'images/littleheart.gif" alt=""/> CommentLuv';
|
307 |
-
add_options_page ( 'CommentLuv settings', $menutitle, $level, $this->slug, array (&$this, 'options_page' ) );
|
308 |
-
}
|
309 |
-
/**
|
310 |
-
* ajax handler
|
311 |
-
* setup by add_action ( 'wp_ajax_removeluv'
|
312 |
-
* called when remove luv link is clicked in comments edit page
|
313 |
-
* with POST['action'] of removeluv, receives cid and _wpnonce
|
314 |
-
*/
|
315 |
-
function ajax_remove_luv(){
|
316 |
-
// check user is allowed to do this
|
317 |
-
$nonce=$_REQUEST['_wpnonce'];
|
318 |
-
$cid = $_REQUEST['cid'];
|
319 |
-
if (! wp_verify_nonce($nonce, 'removeluv'.$cid) ) die("Epic fail");
|
320 |
-
// delete meta if comment id sent with request
|
321 |
-
if($cid){
|
322 |
-
// get meta and set vars if exists
|
323 |
-
$cmeta =get_comment_meta($cid,'cl_data','true');
|
324 |
-
if($cmeta) extract($cmeta);
|
325 |
-
// delete it and call comluv to tell it what happened
|
326 |
-
if(delete_comment_meta($cid,'cl_data')){
|
327 |
-
// can call originator blog here maybe
|
328 |
-
// return the comment id and status code for js processing to hide luv
|
329 |
-
echo "$cid*200";
|
330 |
-
}
|
331 |
-
} else {
|
332 |
-
echo '0';
|
333 |
-
}
|
334 |
-
exit;
|
335 |
}
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
343 |
$options = $this->get_options();
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
$response = wp_remote_head($url,array('method'=>'POST','body'=>$body));
|
353 |
-
$latest = $this->php_version(wp_remote_retrieve_header($response,'version'));
|
354 |
-
$message = wp_remote_retrieve_header($response,'message');
|
355 |
-
if(version_compare($version,$latest,'<')){
|
356 |
-
$options['upgrade'] = $latest;
|
357 |
-
if($message){
|
358 |
-
$options['upgrade_message'] = apply_filters('kindergarten_html',$message);
|
359 |
}
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
if(!is_user_logged_in()){
|
381 |
-
if($options['hide_link_no_url'] == 'spam' && $commentdata->comment_author_url ==''){
|
382 |
-
$commentdata->comment_approved = 'spam';
|
383 |
-
$update = wp_update_comment((array)$commentdata);
|
384 |
-
}
|
385 |
-
if($options['hide_link_no_url'] == 'delete' && $commentdata->comment_author_url == ''){
|
386 |
-
wp_delete_comment($id);
|
387 |
-
return;
|
388 |
-
}
|
389 |
-
// check for matching comment
|
390 |
-
if(!isset($options['hide_link_no_url_match'])){
|
391 |
-
$options['hide_link_no_url_match'] = 'nothing';
|
392 |
-
}
|
393 |
-
$authorurlarr = parse_url($commentdata->comment_author_url);
|
394 |
-
$linkurlarr = parse_url($link);
|
395 |
-
if($options['hide_link_no_url_match'] != 'nothing'){
|
396 |
-
if($authorurlarr['host'] != $linkurlarr['host']){
|
397 |
-
// link has different domain
|
398 |
-
if($options['hide_link_no_url_match'] == 'spam'){
|
399 |
-
$commentdata->comment_approved = 'spam';
|
400 |
-
$update = wp_update_comment((array)$commentdata);
|
401 |
-
}
|
402 |
-
if($options['hide_link_no_url_match'] == 'delete'){
|
403 |
-
wp_delete_comment($id);
|
404 |
-
return;
|
405 |
-
}
|
406 |
}
|
407 |
}
|
408 |
}
|
409 |
-
$prem = 'p' == $_POST['cl_prem'] ? 'p' : 'u';
|
410 |
-
$data = array('cl_post_title'=>$title,'cl_post_url'=>$link,'cl_prem'=>$prem);
|
411 |
-
add_comment_meta($id,'cl_data',$data,'true');
|
412 |
-
}
|
413 |
-
}
|
414 |
-
/**
|
415 |
-
* add my own recurrence schedule
|
416 |
-
* called by add_filter('cron_schedules
|
417 |
-
*
|
418 |
-
* @param mixed $schedules - the current schedules
|
419 |
-
*/
|
420 |
-
function cron_schedules($schedules){
|
421 |
-
$schedules['clfortnightly'] = array(
|
422 |
-
'interval' => 1209600,
|
423 |
-
'display' => __('Twice Monthly')
|
424 |
-
);
|
425 |
-
return $schedules;
|
426 |
-
}
|
427 |
-
/** runs when plugin is deactivated
|
428 |
-
* called by register_deactivation_hook
|
429 |
-
*
|
430 |
-
*/
|
431 |
-
function deactivation(){
|
432 |
-
wp_clear_scheduled_hook('clversion');
|
433 |
-
}
|
434 |
-
/**
|
435 |
-
* detect if request is from a commentluv useragent
|
436 |
-
* called by add_action('init
|
437 |
-
*
|
438 |
-
* ignore if user has set disable_detect in settings
|
439 |
-
*
|
440 |
-
* since 2.90.9.9 - add action for template redirect, we do the sending of the special feed there now
|
441 |
-
*/
|
442 |
-
function detect_useragent(){
|
443 |
-
$options = $this->get_options();
|
444 |
-
// dont do anything if detect is disabled
|
445 |
-
if(isset($_POST['version_check'])){
|
446 |
-
$this->check_version();
|
447 |
-
}
|
448 |
-
if(isset($options['disable_detect']) && $options['disable_detect'] == 'on'){
|
449 |
-
return;
|
450 |
-
}
|
451 |
-
// is this commentluv calling?
|
452 |
-
if (preg_match("/Commentluv/i", $_SERVER['HTTP_USER_AGENT'])){
|
453 |
-
$this->is_commentluv_request = true;
|
454 |
-
ob_start();
|
455 |
-
if(!isset($options['disable_detect'])){
|
456 |
-
remove_all_actions('wp_head');
|
457 |
-
remove_all_actions('wp_footer');
|
458 |
-
// prevent wordpress.com stats from adding stats script
|
459 |
-
global $wp_query;
|
460 |
-
$wp_query->is_feed = true;
|
461 |
-
// use own function to output feed
|
462 |
-
add_action('template_redirect',array(&$this,'send_feed_file'),1);
|
463 |
-
}
|
464 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
}
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
502 |
}
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
if(
|
508 |
-
$imgurl =
|
|
|
|
|
509 |
}
|
510 |
-
$badgecode = $before.'<img alt="CommentLuv badge" src="'.$imgurl.'"/>'.$after;
|
511 |
-
}
|
512 |
-
// or using text
|
513 |
-
if($options['badge_choice'] == 'text'){
|
514 |
-
$badgecode = $before.$options['badge_text'].$after;
|
515 |
}
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
524 |
}
|
525 |
}
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
|
|
552 |
|
553 |
-
}
|
554 |
}
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
}
|
567 |
-
$data = get_comment_meta($cid,'cl_data',true);
|
568 |
-
if(is_array($data)){
|
569 |
-
$data['clicks'] = $data['clicks'] + 1;
|
570 |
-
update_comment_meta($cid,'cl_data',$data);
|
571 |
-
}
|
572 |
-
if($_POST['cl_prem'] == 'true'){
|
573 |
-
$comment = get_commentdata($cid);
|
574 |
-
$refer = get_permalink($comment['comment_post_ID']);
|
575 |
-
// set blocking to false because no response required
|
576 |
-
$response = wp_remote_post($url,array('blocking'=>false,'body'=>array('cl_request'=>'click','refer'=>$refer,'version'=>$this->version)));
|
577 |
-
}
|
578 |
exit;
|
579 |
}
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
586 |
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
}
|
617 |
-
if(!in_array($row->comment_post_ID,$appeared_on_list) && sizeof($appeared_on) < 5){
|
618 |
-
$appeared_on[] = '<a href="'.get_permalink($row->comment_post_ID).'">'.substr(get_the_title($row->comment_post_ID),0,60).'</a>';
|
619 |
-
$appeared_on_list[] = $row->comment_post_ID;
|
620 |
-
}
|
621 |
-
// stop if both lists at 5
|
622 |
-
if(count($appeared_on) >= 5 && count($my_other_posts) >= 5){
|
623 |
-
break;
|
624 |
-
}
|
625 |
}
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
}
|
630 |
-
if(empty($my_other_posts)){
|
631 |
-
$my_other_posts[] = '<a>'.__('If I had made more comments on this site, you would see more of my other posts here',$this->plugin_domain).'</a>';
|
632 |
-
}
|
633 |
-
// get click count on local site
|
634 |
-
$data = get_comment_meta($cid,'cl_data',true);
|
635 |
-
$clickcount = $data['clicks'] ? $data['clicks'] : 0;
|
636 |
-
//DebugBreak();
|
637 |
-
// prem member, try remote fetch of info if not registered on this blog
|
638 |
-
if($cl_prem == 'p' && $isreg == false){
|
639 |
-
$response = wp_remote_post($link,array('body'=>array('cl_request'=>'info','version'=>$this->version,'clickcount'=>$clickcount,'num_comments'=>$num_comments,'appeared_on'=>$appeared_on)));
|
640 |
-
$enabled = wp_remote_retrieve_header($response,'cl_info');
|
641 |
-
if($enabled == 'enabled'){
|
642 |
-
$panel = apply_filters('kindergarten_html',wp_remote_retrieve_body($response));
|
643 |
-
$json = json_encode(array('panel'=>$panel));
|
644 |
-
header ( "Content-Type: application/x-javascript; " );
|
645 |
-
echo $json;
|
646 |
-
exit;
|
647 |
-
} else {
|
648 |
-
$cl_prem = 'u';
|
649 |
-
}
|
650 |
-
}
|
651 |
-
// show registered members panel
|
652 |
-
if($isreg){
|
653 |
-
// get users info
|
654 |
-
$bio = $user->description;
|
655 |
-
if($bio == ''){
|
656 |
-
$bio = __('User has not saved a description in their profile page',$this->plugin_domain);
|
657 |
}
|
658 |
-
|
659 |
-
if(
|
660 |
-
|
661 |
-
} else {
|
662 |
-
$can = 'administrator';
|
663 |
}
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
674 |
$json = json_encode(array('panel'=>$panel));
|
675 |
header ( "Content-Type: application/x-javascript; " );
|
676 |
echo $json;
|
677 |
exit;
|
|
|
|
|
678 |
}
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
$
|
684 |
-
$
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
|
|
|
|
|
|
|
|
699 |
$json = json_encode(array('panel'=>$panel));
|
700 |
header ( "Content-Type: application/x-javascript; " );
|
701 |
echo $json;
|
702 |
exit;
|
703 |
}
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
$
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
778 |
}
|
779 |
-
if ($options ['infopanel'] == 'on') {
|
780 |
-
$commentcontent .= '<span class="heart_tip_box"><img class="heart_tip '.$data['cl_prem'].' '.$comment->comment_ID.'" alt="My Profile" style="border:0" width="16" height="14" src="' . $this->plugin_url . 'images/littleheart'.$hearticon.'.gif"/></span>';
|
781 |
-
}
|
782 |
-
$commentcontent.= '</span>';
|
783 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
784 |
}
|
785 |
}
|
786 |
-
// store new content in this comments comment_content cell
|
787 |
-
$comment->comment_content = $commentcontent;
|
788 |
-
// fill new array with this comment
|
789 |
-
$new_commentarray[] = $comment;
|
790 |
-
}
|
791 |
-
// admin page or public page?
|
792 |
-
if($isadminpage){
|
793 |
-
// is being called by comment_text filter so expecting just content
|
794 |
-
return $commentcontent;
|
795 |
-
} else {
|
796 |
-
// called from comments_array filter so expecting array of objects
|
797 |
-
return $new_commentarray;
|
798 |
}
|
|
|
|
|
|
|
|
|
799 |
}
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
$return[] = array('type'=>'
|
856 |
}
|
857 |
-
|
858 |
-
|
859 |
-
echo $response;
|
860 |
-
exit;
|
861 |
}
|
862 |
-
//
|
863 |
-
$
|
864 |
-
|
865 |
-
|
|
|
866 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
867 |
$rss->set_useragent('Commentluv /'.$this->version.' (Feed Parser; http://www.commentluv.com; Allow like Gecko) Build/20110502' );
|
868 |
-
$rss->set_feed_url ( add_query_arg(array('commentluv'=>'true'),$url) );
|
869 |
$rss->enable_cache ( FALSE );
|
870 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
871 |
$rss->init();
|
872 |
-
$su = $rss->subscribe_url();
|
873 |
$ferror = $rss->error();
|
874 |
-
|
875 |
-
|
876 |
-
if($ferror || strstr($ferror,'could not be found') && !strstr($su,'feed')){
|
877 |
unset($rss);
|
878 |
$rss = new SimplePie();
|
879 |
$rss->set_useragent('Commentluv /'.$this->version.' (Feed Parser; http://www.commentluv.com; Allow like Gecko) Build/20110502' );
|
880 |
-
$rss->enable_cache ( FALSE );
|
881 |
-
|
882 |
-
if(strstr($url,'blogspot')){
|
883 |
-
$url = trailingslashit($url).'feeds/posts/default/';
|
884 |
-
} else {
|
885 |
-
$url = add_query_arg(array('feed'=>'atom'),$url);
|
886 |
-
}
|
887 |
-
$rss->set_feed_url($url);
|
888 |
$rss->init();
|
889 |
$ferror = $rss->error();
|
890 |
-
if
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
$rss->
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
if(class_exists('SimplePie_File')){
|
904 |
-
$rawfile = new SimplePie_File($suburl, $rss->timeout, 5, null, $rss->useragent, $rss->force_fsockopen);
|
905 |
-
} elseif (class_exists($rss->file_class)){
|
906 |
-
$rawfile = new $rss->file_class($suburl, $rss->timeout, 5, null, $rss->useragent, $rss->force_fsockopen);
|
907 |
-
}
|
908 |
-
if(isset($rawfile->body)){
|
909 |
-
$rawfile = $rawfile->body;
|
910 |
-
} else {
|
911 |
-
$rawfile = __('Raw file could not be found',$this->plugin_domain);
|
912 |
-
}
|
913 |
}
|
914 |
}
|
915 |
}
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
}
|
932 |
-
if($prem_msg){
|
933 |
-
$prem_msg = $prem_msg[0]['data'];
|
934 |
}
|
935 |
-
|
936 |
-
|
937 |
-
$
|
938 |
-
|
939 |
-
|
940 |
-
|
|
|
|
|
|
|
|
|
941 |
|
942 |
-
|
943 |
|
944 |
-
|
945 |
-
|
946 |
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
}
|
955 |
-
$arr[] = array('type'=>$type,'title'=>htmlspecialchars_decode(strip_tags($item->get_title())),'link'=>$item->get_permalink(),'p'=>$p);
|
956 |
-
$g--;
|
957 |
-
if($g < 1){
|
958 |
-
break;
|
959 |
-
}
|
960 |
}
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
|
|
|
|
972 |
}
|
973 |
}
|
974 |
-
if($
|
975 |
-
$arr[] = array('type'=>'
|
976 |
}
|
977 |
-
$response = json_encode(array('error'=>'','items'=>$arr,'meta'=>$meta));
|
978 |
-
} else {
|
979 |
-
// had an error trying to read the feed
|
980 |
-
$response = json_encode(array('error'=>$error,'meta'=>$meta,'rawfile'=>htmlspecialchars($rawfile)));
|
981 |
-
}
|
982 |
-
unset($rss);
|
983 |
-
header( "Content-Type: application/json" );
|
984 |
-
echo $response;
|
985 |
-
exit;
|
986 |
-
}
|
987 |
-
/**
|
988 |
-
* find number of approved comments in the past 14 days to have a commentluv link
|
989 |
-
* called in check_version
|
990 |
-
* since 2.90.8
|
991 |
-
* @return int
|
992 |
-
*/
|
993 |
-
function get_numluv(){
|
994 |
-
global $wpdb;
|
995 |
-
$query = $wpdb->prepare('SELECT count(*) FROM '.$wpdb->commentmeta.' m JOIN '.$wpdb->comments.' c ON m.comment_id = c.comment_ID WHERE m.meta_key = %s AND c.comment_approved = %s AND c.comment_date > NOW() - INTERVAL 14 DAY','cl_data','1');
|
996 |
-
return intval($wpdb->get_var($query));
|
997 |
-
}
|
998 |
-
/** get_options
|
999 |
-
* This function sets default options and handles a reset to default options
|
1000 |
-
* @param string $reset = 'no' - whether to return default settings
|
1001 |
-
* return array
|
1002 |
-
*/
|
1003 |
-
function get_options($reset = 'no') {
|
1004 |
-
// see if we offer registration incentive
|
1005 |
-
$register_link = '';
|
1006 |
-
if(get_option('users_can_register')){
|
1007 |
-
$register_link = apply_filters('register','<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>');
|
1008 |
-
}
|
1009 |
-
// default values
|
1010 |
-
$this->handle_load_domain ();
|
1011 |
-
$default = array ('version'=>$this->version,'enable'=>'yes','enable_for'=>'both', 'default_on' => 'on', 'default_on_admin'=>'on',
|
1012 |
-
'badge_choice' => 'drop_down', 'badge_type'=>'default', 'link'=>'off','infopanel'=>'on', 'infoback'=>'white', 'infotext'=>'black',
|
1013 |
-
'comment_text'=>'[name] '.__('recently posted',$this->plugin_domain).'...[lastpost]', 'whogets'=>'registered', 'dofollow' => 'registered',
|
1014 |
-
'unreg_user_text'=>__('If you register as a user on my site, you can get your 10 most recent blog posts to choose from in this box.',$this->plugin_domain).' '.$register_link,
|
1015 |
-
'unreg_user_text_panel'=>__('If this user had registered to my site then they could get 10 last posts to choose from when they comment and you would be able to see a list of their recent posts in this panel',$this->plugin_domain),
|
1016 |
-
'template_insert'=>'','minifying'=>'','api_url'=>admin_url('admin-ajax.php'),'author_name'=>'author','email_name'=>'email','url_name'=>'url','comment_name'=>'comment',
|
1017 |
-
'hide_link_no_url'=>'nothing','hide_link_no_url_match'=>'nothing');
|
1018 |
-
$options = get_option ( $this->db_option, $default);
|
1019 |
-
// return the options
|
1020 |
-
if($reset == 'yes'){
|
1021 |
-
return $default;
|
1022 |
}
|
1023 |
-
if(
|
1024 |
-
$
|
1025 |
-
}
|
1026 |
-
if(!$options['enable']){
|
1027 |
-
$options['enable'] = 'yes';
|
1028 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1029 |
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
}
|
1067 |
-
// for version before 2.9
|
1068 |
-
if(version_compare($installed_version,'2.9','<')){
|
1069 |
-
// make any changes to this new versions options if needed and update
|
1070 |
-
update_option($this->db_option,$this->get_options('yes'));
|
1071 |
-
}
|
1072 |
-
// new addition to technical settings after 2.90.1 release
|
1073 |
-
if(version_compare($installed_version,'2.9.0.1','<')){
|
1074 |
-
$options['api_url'] = admin_url('admin-ajax.php');
|
1075 |
-
$options['enable'] = 'yes';
|
1076 |
-
update_option($this->db_option,$options);
|
1077 |
-
}
|
1078 |
-
// update cl_version in db
|
1079 |
-
if($this->php_version($this->version) != $installed_version){
|
1080 |
-
update_option('cl_version',$this->version);
|
1081 |
-
}
|
1082 |
-
// has the comment meta table?
|
1083 |
-
global $wpdb;
|
1084 |
-
$query = $wpdb->prepare("SHOW tables LIKE %s",$wpdb->commentmeta);
|
1085 |
-
$dbtable = $wpdb->get_var($query);
|
1086 |
-
//$o['dbtable'] = $dbtable;
|
1087 |
-
if(!$dbtable){
|
1088 |
-
add_action('admin_notices',create_function('','echo "<div class=\"error\">'.__('Your Wordpress install is missing the <strong>wp_commentmeta</strong> table!',$pd).'<br>'.__(' CommentLuv cannot work without this table please see this wordpress forum post to learn how to add one ->',$pd).'<a target=\"_blank\" href=\"http://wordpress.org/support/topic/wp_commentmeta-table-a39xxxx2_blogwp_commentmeta-doesnt-exist?replies=7#post-1378281\">'.__('Missing wp_commentmeta table',$pd).'</a></div>";'));
|
1089 |
-
}
|
1090 |
}
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
function is_enabled(){
|
1096 |
-
$options = $this->get_options();
|
1097 |
-
// see if we need to add here or not
|
1098 |
-
if(($options['enable_for'] == 'posts' && is_page()) || ($options['enable_for'] == 'pages' && !is_page())){
|
1099 |
-
return false;
|
1100 |
-
}
|
1101 |
-
if($options['enable'] != 'yes'){
|
1102 |
-
return false;
|
1103 |
-
}
|
1104 |
-
return true;
|
1105 |
-
}
|
1106 |
-
/**
|
1107 |
-
* called by apply_filter('kindergarten_html
|
1108 |
-
* Used to clean $input to only allow a kiddy set of html tags
|
1109 |
-
*
|
1110 |
-
* @param string $input - the string to be cleaned
|
1111 |
-
* @return string
|
1112 |
-
*/
|
1113 |
-
function kindergarten_html($input){
|
1114 |
-
$allowedtags = array(
|
1115 |
-
'h1' => array(),
|
1116 |
-
'br' => array(),
|
1117 |
-
'a' => array('href' => array(),'title' => array(),'rel' => array(),'target'=>array(), 'class'=>array()),
|
1118 |
-
'small' =>array(),
|
1119 |
-
'p' =>array( 'class'=>array()),
|
1120 |
-
'strong' => array(),
|
1121 |
-
'img' => array('src' => array(),'alt' => array(),'width' => array(),'height' => array(),'align'=> array()),
|
1122 |
-
'span' => array('class'=>array())
|
1123 |
-
);
|
1124 |
-
return wp_kses($input,$allowedtags);
|
1125 |
-
}
|
1126 |
-
/**
|
1127 |
-
* Ajax handler for the subscribe button on the settings page.
|
1128 |
-
* called by add_action ( 'wp_ajax_notify_signup'
|
1129 |
-
*/
|
1130 |
-
function notify_signup(){
|
1131 |
-
//DebugBreak();
|
1132 |
-
global $current_user;
|
1133 |
-
$email = $current_user->user_email;
|
1134 |
-
$firstname = $current_user->first_name;
|
1135 |
-
if(!$firstname){
|
1136 |
-
$firstname = $current_user->user_nicename;
|
1137 |
-
}
|
1138 |
-
$message = "\n Email: ".$email."\n\n Name: ".$firstname."\n\n Meta: settings_page_289"."\n\n";
|
1139 |
-
$to = 'cl_notify29@aweber.com';
|
1140 |
-
$headers = 'From: '.$firstname.' <'.$email.'>'."\r\n\\";
|
1141 |
-
$mail = wp_mail($to,'cl_notify',$message,$headers);
|
1142 |
-
if($mail === true){
|
1143 |
-
$options = $this->get_options();
|
1144 |
-
$options['subscribed'] = true;
|
1145 |
-
update_option($this->db_option,$options);
|
1146 |
-
}
|
1147 |
-
$return = array('success'=>$mail,'email'=>$email);
|
1148 |
-
// return response
|
1149 |
-
$response = json_encode($return);
|
1150 |
-
// response output
|
1151 |
-
header( "Content-Type: application/json" );
|
1152 |
-
echo $response;
|
1153 |
-
// IMPORTANT: don't forget to "exit"
|
1154 |
-
exit;
|
1155 |
}
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
return
|
1187 |
-
}
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
}
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
* @param (obj) $object - the query object
|
1228 |
-
* @return $foundposts - need to return this if the request is not from a commentluv api or plugin
|
1229 |
-
*
|
1230 |
-
* deprecated in 2.90.9.9 due to new 3.4 wp query code messing up with static homepages.
|
1231 |
-
* have to use just 10 recent posts, does not detect author or category urls now. (no one uses them!)
|
1232 |
-
*/
|
1233 |
-
function send_feed($foundposts,$object){
|
1234 |
-
if(headers_sent() == true){
|
1235 |
-
return $foundposts;
|
1236 |
-
}
|
1237 |
$options = $this->get_options();
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1246 |
}
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1252 |
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
<link>'.get_permalink($post->ID).'</link>
|
1276 |
-
<type>blog</type>
|
1277 |
-
</item>';
|
1278 |
-
}
|
1279 |
-
} else {
|
1280 |
-
$feed .= '<item><title>'.__('No Posts Were Found!',$pd).'</title>
|
1281 |
<link>'.get_permalink($post->ID).'</link>
|
|
|
1282 |
</item>';
|
1283 |
}
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
}
|
1289 |
-
|
|
|
|
|
|
|
1290 |
}
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
$
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
$
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
'</item>';
|
1334 |
-
}
|
1335 |
-
} else {
|
1336 |
-
$feed .= '<item><title>'.__('No Posts Were Found!',$pd).'</title>'.
|
1337 |
'<link>'.get_permalink($post->ID).'</link>'.
|
|
|
1338 |
'</item>';
|
1339 |
-
}
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
exit;
|
1345 |
-
|
1346 |
}
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
add_action ( 'comment_form',array(&$this,'add_fields')); // add fields to form
|
1353 |
-
add_action ( 'wp_print_styles',array(&$this,'add_style')); // add style
|
1354 |
-
add_action ( 'template_redirect',array(&$this,'add_script')); // add commentluv script
|
1355 |
-
add_action ( 'admin_print_scripts-edit-comments.php', array (&$this, 'add_removeluv_script') ); // add the removeluv script to admin page
|
1356 |
-
add_action ( 'wp_footer',array(&$this,'add_footer')); // add localize to footer
|
1357 |
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1384 |
}
|
|
|
|
|
|
|
1385 |
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
?>
|
1407 |
<div class="wrap">
|
1408 |
<h2><?php _e('CommentLuv Settings v',$this->plugin_domain);?><?php echo $this->version;?></h2>
|
@@ -1410,7 +1410,7 @@
|
|
1410 |
<div id="mainblock" style="float: left; width:710px">
|
1411 |
<form method="post" action="options.php">
|
1412 |
<?php settings_fields( 'commentluv_options_group' ); // the name given in admin init
|
1413 |
-
|
1414 |
?>
|
1415 |
<div class="dbx-content">
|
1416 |
<table class="widefat">
|
@@ -1426,11 +1426,11 @@
|
|
1426 |
<td>
|
1427 |
<p><?php _e('Do you like CommentLuv? How about an even better version with much more control over dofollow and some awesome social enticements that will make your posts go viral by offering your readers more choice of posts if they +1, Like or tweet your post? Get CommentLuv Premium Today!',$pd);?></p>
|
1428 |
<?php
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
?>
|
1435 |
<div id="notify_message"></div>
|
1436 |
</td>
|
@@ -1509,9 +1509,9 @@
|
|
1509 |
<input type="radio" class="radio" name="<?php echo $dbo;?>[badge_choice]" value="custom" <?php checked($o['badge_choice'],'custom');?>/>
|
1510 |
<input type="text" name="<?php echo $dbo;?>[custom_image_url]" value="<?php if(isset($o['custom_image_url'])) echo $o['custom_image_url'];?>"/>
|
1511 |
<?php
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
} ?>
|
1516 |
</td>
|
1517 |
<td>
|
@@ -1530,8 +1530,8 @@
|
|
1530 |
<td><label for="<?php echo $dbo;?>[infotext]"><?php _e('Info panel text color',$pd);?></label><br><input type="text" size="6" name="<?php echo $dbo;?>[infotext];?>" value="<?php echo $o['infotext'];?>"/></td>
|
1531 |
<td></td>
|
1532 |
<?php
|
1533 |
-
|
1534 |
-
|
1535 |
?>
|
1536 |
<td style=<?php echo $tdstyle;?>><span style=<?php echo $spanstyle;?>><?php _e('Example text and background color',$pd);?></span></td>
|
1537 |
</tr>
|
@@ -1564,23 +1564,23 @@
|
|
1564 |
<br>(<?php _e('Message will not be shown if you do not have registrations enabled',$this->plugin_domain);?>)
|
1565 |
<br><textarea rows="5" style="width: 95%" name="<?php echo $dbo;?>[unreg_user_text]"><?php echo $o['unreg_user_text'];?></textarea>
|
1566 |
<?php
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
?>
|
1575 |
</td>
|
1576 |
<td colspan="2" style="width:125px;">
|
1577 |
<?php // show warning if registration is not enabled
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
?>
|
1585 |
</td>
|
1586 |
</tr>
|
@@ -1730,14 +1730,14 @@
|
|
1730 |
<tr>
|
1731 |
<td colspan="4"><textarea style="width: 99%" rows="5">
|
1732 |
<?php
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
|
1740 |
-
|
1741 |
|
1742 |
?>
|
1743 |
</textarea>
|
@@ -1745,9 +1745,29 @@
|
|
1745 |
<td>
|
1746 |
<?php _e('You can copy this information and send it to me if I request it',$pd);?>
|
1747 |
</td>
|
1748 |
-
</tr>
|
1749 |
</tbody>
|
1750 |
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1751 |
|
1752 |
</div>
|
1753 |
<div class="submit"><input class="button-primary" id="clsubmit" type="submit" name="Submit" value="<?php _e('Save Settings',$this->plugin_domain);?>" /></div>
|
@@ -1755,7 +1775,7 @@
|
|
1755 |
<h3><?php _e('Reset Settings',$this->plugin_domain);?></h3>
|
1756 |
<form method="post" action="options.php">
|
1757 |
<?php settings_fields( 'commentluv_options_group' ); // the name given in admin init
|
1758 |
-
|
1759 |
?>
|
1760 |
<input type="hidden" name="<?php echo $this->db_option;?>[reset]" value="yes"/>
|
1761 |
<input style="background-color: red;" type="submit" onclick="<?php echo 'if(confirm(\''.$javamsg.'\') != true) { return false; } else { return true; } ';?>" value="<?php _e('Reset',$this->plugin_domain);?>" name="submit"/>
|
@@ -1779,15 +1799,15 @@
|
|
1779 |
<tr class="alt"><td colspan="2"><?php _e('News',$this->plugin_domain);?>:</td></tr>
|
1780 |
<tr><td colspan="2">
|
1781 |
<?php
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
?>
|
1792 |
<ul>
|
1793 |
<li>
|
@@ -1797,10 +1817,10 @@
|
|
1797 |
</li>
|
1798 |
</ul>
|
1799 |
<?php
|
1800 |
-
}
|
1801 |
}
|
1802 |
}
|
1803 |
}
|
|
|
1804 |
|
1805 |
?>
|
1806 |
</td></tr>
|
@@ -1850,32 +1870,32 @@
|
|
1850 |
</div>
|
1851 |
<?php
|
1852 |
|
1853 |
-
|
1854 |
|
1855 |
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1862 |
}
|
1863 |
-
|
1864 |
-
// start commentluv class engines
|
1865 |
-
if (class_exists ( 'commentluv' )) :
|
1866 |
-
$commentluv = new commentluv ( );
|
1867 |
-
// confirm warp capability
|
1868 |
-
if (isset ( $commentluv )) {
|
1869 |
-
// engage
|
1870 |
-
register_activation_hook ( __FILE__, array (&$commentluv, 'install' ) );
|
1871 |
-
}
|
1872 |
-
endif;
|
1873 |
-
|
1874 |
-
function cl_display_badge(){
|
1875 |
-
global $commentluv;
|
1876 |
-
if(isset($commentluv)){
|
1877 |
-
$commentluv->display_badge();
|
1878 |
-
}
|
1879 |
|
|
|
|
|
|
|
|
|
1880 |
}
|
|
|
|
|
1881 |
?>
|
1 |
<?php /* commentluv
|
2 |
+
Plugin Name: CommentLuv
|
3 |
+
Plugin URI: http://comluv.com/
|
4 |
+
Description: Reward your readers by automatically placing a link to their last blog post at the end of their comment. Encourage a community and discover new posts.
|
5 |
+
Version: 2.92.9
|
6 |
+
Author: Andy Bailey
|
7 |
+
Author URI: http://www.commentluv.com
|
8 |
+
Copyright (C) <2011> <Andy Bailey>
|
9 |
|
10 |
+
This program is free software: you can redistribute it and/or modify
|
11 |
+
it under the terms of the GNU General Public License as published by
|
12 |
+
the Free Software Foundation, either version 3 of the License, or
|
13 |
+
(at your option) any later version.
|
14 |
|
15 |
+
This program is distributed in the hope that it will be useful,
|
16 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
+
GNU General Public License for more details.
|
19 |
|
20 |
+
You should have received a copy of the GNU General Public License
|
21 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*/
|
23 |
+
if (! class_exists ( 'commentluv' )) {
|
24 |
+
// let class begin
|
25 |
+
class commentluv {
|
26 |
+
//localization domain
|
27 |
+
var $plugin_domain = 'commentluv';
|
28 |
+
var $plugin_url;
|
29 |
+
var $plugin_dir;
|
30 |
+
var $db_option = 'commentluv_options';
|
31 |
+
var $version = "2.92.9";
|
32 |
+
var $slug = 'commentluv-options';
|
33 |
+
var $localize;
|
34 |
+
var $is_commentluv_request = false;
|
35 |
|
36 |
+
/** commentluv
|
37 |
+
* This is the constructor, it runs as soon as the class is created
|
38 |
+
* Use this to set up hooks, filters, menus and language config
|
39 |
+
*/
|
40 |
+
function __construct() {
|
41 |
+
global $wp_version, $pagenow, $wp_actions;
|
42 |
+
$options = $this->get_options();
|
43 |
+
// try to add jetpack_module_loaded_comments action so it doesn't load
|
44 |
+
if(!isset($options['allow_jpc'])){
|
45 |
+
$wp_actions['jetpack_module_loaded_comments'] = 1;
|
46 |
+
}
|
47 |
+
// pages where this plugin needs translation
|
48 |
+
$local_pages = array ('plugins.php', 'options-general.php' );
|
49 |
+
// check if translation needed on current page
|
50 |
+
if (in_array ( $pagenow, $local_pages ) || (isset($_GET['page']) && in_array ( $_GET ['page'], $local_pages ))) {
|
51 |
+
$this->handle_load_domain ();
|
52 |
+
}
|
53 |
+
$exit_msg = __( 'CommentLuv requires Wordpress 3.0 or newer.', $this->plugin_domain ) . '<a href="http://codex.wordpress.org/Upgrading_Wordpress">' . __ ( 'Please Update!', $this->plugin_domain ) . '</a>';
|
54 |
+
// can you dig it?
|
55 |
+
if (version_compare ( $wp_version, "3.0", "<" )) {
|
56 |
+
deactivate_plugins(basename(__FILE__)); //deactivate me
|
57 |
+
wp_die ( $exit_msg ); // no diggedy
|
58 |
+
}
|
59 |
+
// activation/deactivation
|
60 |
+
register_activation_hook(__FILE__, array(&$this,'activation'));
|
61 |
+
register_deactivation_hook(__FILE__, array(&$this,'deactivation'));
|
62 |
+
// manual set install and activate, wordpress wont fire the activation hook on auto upgrade plugin
|
63 |
+
$cl_version = get_option('cl_version');
|
64 |
+
if($this->version != $cl_version){
|
65 |
+
$this->install();
|
66 |
+
$this->activation();
|
67 |
+
}
|
68 |
+
// plugin dir and url
|
69 |
+
$this->plugin_url = trailingslashit ( WP_PLUGIN_URL . '/' . dirname ( plugin_basename ( __FILE__ ) ) );
|
70 |
+
$this->plugin_dir = dirname(__FILE__);
|
71 |
+
if(defined('DOING_AJAX') && DOING_AJAX){
|
72 |
+
add_action ( 'wp_ajax_removeluv', array (&$this, 'ajax_remove_luv') ); // handle the call to the admin-ajax for removing luv
|
73 |
+
add_action ( 'wp_ajax_notify_signup', array(&$this,'notify_signup')); // ajax handler for settings page subscribe button
|
74 |
+
add_action ( 'wp_ajax_nopriv_cl_ajax',array(&$this,'do_ajax'));
|
75 |
+
add_action ( 'wp_ajax_cl_ajax',array(&$this,'do_ajax'));
|
76 |
+
} else {
|
77 |
+
add_action ( 'clversion', array (&$this,'check_version') ); // check commentluv version
|
78 |
+
add_action ( 'init', array (&$this,'init') ); // to register styles and scripts
|
79 |
+
add_action ( 'admin_init', array (&$this, 'admin_init' ) ); // to register settings group
|
80 |
+
add_action ( 'admin_menu', array (&$this, 'admin_menu' ) ); // to setup menu link for settings page
|
81 |
+
add_action ( 'admin_print_scripts-settings_page_commentluv-options', array(&$this,'add_settings_page_script')); // script for settings page ajax function
|
82 |
+
add_action ( 'admin_print_styles-settings_page_commentluv-options', array(&$this,'add_settings_page_style')); // script for settings page ajax function
|
83 |
+
add_action ( 'init', array(&$this,'detect_useragent'));
|
84 |
+
}
|
85 |
+
// filters
|
86 |
+
add_filter ( 'cron_schedules', array (&$this, 'cron_schedules') ); // for my own recurrence
|
87 |
+
add_filter ( 'plugin_action_links', array (&$this, 'plugin_action_link' ), - 10, 2 ); // add a settings page link to the plugin description. use 2 for allowed vars
|
88 |
+
// add_filter ( 'found_posts', array(&$this,'send_feed'),-1,2); // sends post titles and urls only - deprecated in 2.90.9.9
|
89 |
+
add_filter ( 'kindergarten_html', array(&$this,'kindergarten_html')); // for cleaning html
|
90 |
|
91 |
+
//$this->check_version();
|
92 |
+
if(!isset($options['enable']) || ( isset($options['enable']) && $options['enable'] != 'no')){
|
93 |
+
$this->setup_hooks();
|
94 |
+
}
|
95 |
|
96 |
|
97 |
+
}
|
98 |
+
/**
|
99 |
+
* PHP4 constructor
|
100 |
+
*/
|
101 |
+
function commentluv() {
|
102 |
+
$this->__construct();
|
103 |
+
}
|
104 |
+
/** runs when plugin is activated
|
105 |
+
* called by register_activation_hook
|
106 |
+
*
|
107 |
+
*/
|
108 |
+
function activation(){
|
109 |
+
// only add if it doesn't exist yet
|
110 |
+
$sched = wp_next_scheduled('clversion');
|
111 |
+
if(false === $sched){
|
112 |
+
// set up cron for version check
|
113 |
+
$rnd = mt_rand(5,604800);
|
114 |
+
wp_schedule_event(time() - $rnd,'clfortnightly','clversion');
|
115 |
}
|
116 |
+
// removed w3 total cache stuff due to Freds updates causing fatal errors
|
117 |
+
}
|
118 |
+
/**
|
119 |
+
* Adds fields to comment area
|
120 |
+
* called by add_action('comment_form
|
121 |
+
*/
|
122 |
+
function add_fields(){
|
123 |
+
global $clbadgeshown;
|
124 |
+
$options = $this->get_options();
|
125 |
+
if(!$this->is_enabled()){
|
126 |
+
return;
|
127 |
+
}
|
128 |
+
$author_name = $options['author_name'];
|
129 |
+
$email_name = $options['email_name'];
|
130 |
+
$url_name = $options['url_name'];
|
131 |
+
// handle logged on user
|
132 |
+
if(is_user_logged_in()){
|
133 |
+
global $userdata;
|
134 |
+
get_currentuserinfo();
|
135 |
+
$author = $userdata->display_name;
|
136 |
+
$userid = $userdata->ID;
|
137 |
+
$url = $userdata->user_url;
|
138 |
+
if(!strstr($url,'http://') && $url != ''){
|
139 |
+
$url = 'http://'.$url;
|
140 |
+
}
|
141 |
+
// check for s2 member pluin, add url from it's custom registration fields
|
142 |
+
if(defined('WS_PLUGIN__S2MEMBER_VERSION') && isset($userdata->wp_s2member_custom_fields['website'])){
|
143 |
+
$url = $userdata->wp_s2member_custom_fields['website'];
|
144 |
+
}
|
145 |
+
// check for multisite
|
146 |
+
if(is_multisite()){
|
147 |
+
if(!$url || $url == 'http://'){
|
148 |
+
$userbloginfo = get_blogs_of_user($userid,1);
|
149 |
+
$url = $userbloginfo[1] -> siteurl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
152 |
+
// final check of url
|
153 |
+
if($url == 'http://'){
|
154 |
+
$url = '';
|
|
|
|
|
|
|
155 |
}
|
156 |
+
// spit out hidden fields
|
157 |
+
echo '<input type="hidden" id="'.$author_name.'" name="'.$author_name.'" value="'.$author.'"/>';
|
158 |
+
// if buddypress, don't hide field
|
159 |
+
if(function_exists('bp_core_setup_globals')){
|
160 |
+
$input_type = 'text';
|
161 |
+
} else {
|
162 |
+
$input_type = 'hidden';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
}
|
164 |
+
echo '<input type="'.$input_type.'" id="'.$url_name.'" name="'.$url_name.'" value="'.$url.'"/>';
|
165 |
}
|
166 |
+
// add hidden fields for holding information about type,choice,html and request for every user
|
167 |
+
echo '<input type="hidden" name="cl_post_title" id="cl_post_title"/>';
|
168 |
+
echo '<input type="hidden" name="cl_post_url" id="cl_post_url"/>';
|
169 |
+
echo '<input type="hidden" name="cl_prem" id="cl_prem"/>';
|
170 |
+
// show badge (unless user set to manual insert)
|
171 |
+
if(($clbadgeshown == false && !isset($options['template_insert'])) || (isset($options['template_insert']) && $options['template_insert'] == '') ){
|
172 |
+
$this->display_badge();
|
173 |
+
}
|
174 |
+
}
|
175 |
+
function add_footer(){
|
176 |
+
$minifying = 'off';
|
177 |
+
extract($this->get_options());
|
178 |
+
if($minifying != 'on' || !$this->is_enabled()){
|
179 |
+
return;
|
180 |
+
}
|
181 |
+
// from the excellent book wp-ajax (http://www.wpajax.com/)
|
182 |
+
$data = "var cl_settings = {";
|
183 |
+
$arr = array();
|
184 |
+
$vars = $this->localize;
|
185 |
+
if(is_array($vars)){
|
186 |
+
foreach ($vars as $key => $value) {
|
187 |
+
$arr[count($arr)] = $key . " : '" . esc_js($value) . "'";
|
188 |
+
}
|
189 |
+
$data .= implode(",",$arr); $data .= "};";
|
190 |
+
echo "<script type='text/javascript'>\n";
|
191 |
+
echo "/* <![CDATA[ */\n";
|
192 |
+
echo $data;
|
193 |
+
echo "\n/* ]]> */\n";
|
194 |
+
echo "</script>\n";
|
195 |
+
}
|
196 |
+
}
|
197 |
+
/**
|
198 |
+
* called by add_filter('comment_row_actions
|
199 |
+
* adds another link to the comment row in admin for removing the luv link
|
200 |
+
* @param array $actions - the existing actions
|
201 |
+
*/
|
202 |
+
function add_removeluv_link($actions){
|
203 |
+
global $post;
|
204 |
+
$user_can = current_user_can('edit_posts', $post->ID);
|
205 |
+
$cid = get_comment_ID();
|
206 |
+
$data = get_comment_meta($cid,'cl_data');
|
207 |
+
if($data && is_array($data)){
|
208 |
+
if($user_can){
|
209 |
+
$nonce= wp_create_nonce ('removeluv'.get_comment_ID());
|
210 |
+
$actions['Remove-luv'] = '<a class="removeluv :'.$cid.':'.$nonce.'" href="javascript:">Remove Luv</a>';
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
}
|
212 |
+
}
|
213 |
+
return $actions;
|
214 |
+
}
|
215 |
+
/**
|
216 |
+
* called by add_action('admin_print_scripts-edit-comments.php'
|
217 |
+
* load the script to handle the removluv link
|
218 |
+
*
|
219 |
+
*/
|
220 |
+
function add_removeluv_script(){
|
221 |
+
wp_enqueue_script ( 'commentluv', $this->plugin_url . 'js/adminremoveluv.js', array ('jquery' ),$this->version );
|
222 |
+
}
|
223 |
+
/**
|
224 |
+
* called by add_action('template_redirect in setup_hooks()
|
225 |
+
* used to add the commentluv script and localized settings (if not using minifying compatibility)
|
226 |
+
*/
|
227 |
+
function add_script(){
|
228 |
+
$minifying = 'off';
|
229 |
+
$template_insert = false;
|
230 |
+
$options = $this->get_options();
|
231 |
+
extract($options);
|
232 |
+
if(!$this->is_enabled()){
|
233 |
+
return;
|
234 |
+
}
|
235 |
+
wp_enqueue_script('commentluv_script');
|
236 |
+
$this->localize = array ('name' => $author_name, 'url' => $url_name, 'comment' => $comment_name, 'email' => $email_name,
|
237 |
+
'infopanel' => $infopanel, 'default_on' => $default_on, 'default_on_admin' => $default_on_admin,
|
238 |
+
'cl_version' => $this->version, 'images' => $this->plugin_url . 'images/', 'api_url' => $api_url,
|
239 |
+
'_fetch' => wp_create_nonce('fetch'), '_info' => wp_create_nonce('info'),
|
240 |
+
'infoback' => $infoback, 'infotext'=>$infotext,'template_insert'=>$template_insert, 'logged_in'=>is_user_logged_in(),
|
241 |
+
'refer' => get_permalink(),
|
242 |
+
'no_url_message'=>__('Please enter a URL and then click the CommentLuv checkbox if you want to add your last blog post',$this->plugin_domain),
|
243 |
+
'no_http_message'=>__('Please use http:// in front of your url',$this->plugin_domain),
|
244 |
+
'no_url_logged_in_message'=>__('You need to visit your profile in the dashboard and update your details with your site URL',$this->plugin_domain),
|
245 |
+
'no_info_message'=>__('No info was available or an error occured',$this->plugin_domain));
|
246 |
+
if($minifying != 'on'){
|
247 |
+
wp_localize_script('commentluv_script','cl_settings',$this->localize);
|
248 |
+
}
|
249 |
|
250 |
|
251 |
+
}
|
252 |
+
/**
|
253 |
+
* called by add_action('wp_print_styles in setup_hooks()
|
254 |
+
* Used to add the stylesheet for commentluv
|
255 |
+
*/
|
256 |
+
function add_style(){
|
257 |
+
if(!$this->is_enabled()){
|
258 |
+
return;
|
259 |
}
|
260 |
+
wp_enqueue_style('commentluv_style');
|
261 |
+
}
|
262 |
+
/**
|
263 |
+
* Adds scripts to settings page. Only loads scripts if the settings page is being shown
|
264 |
+
* Called by add_action('admin_print_scripts-settings_page_commentluv-options'
|
265 |
+
* use localize so messages in javascript are internationalized
|
266 |
+
*/
|
267 |
+
function add_settings_page_script (){
|
268 |
+
wp_enqueue_script ('notify_signup', $this->plugin_url . 'js/notify_signup.js', array('jquery'),$this->version );
|
269 |
+
wp_localize_script ( 'notify_signup', 'notify_signup_settings', array('wait_message'=>__('Please wait',$this->plugin_domain),'notify_success1' => __('Please check your inbox, an email will be sent to',$this->plugin_domain), 'notify_success2'=>__('in the next few minutes with a confirmation link',$this->plugin_domain), 'notify_fail'=>__('An error happened with the request. Try signing up at the site',$this->plugin_domain),'image_url'=>$this->plugin_url.'images/','default_image'=>'CL91_default.png', 'white'=>'CL91_White.gif','black'=>'CL91_Black.gif','none'=>'nothing.gif'));
|
270 |
+
wp_enqueue_script('thickbox',null,array('jquery'));
|
271 |
+
echo "<link rel='stylesheet' href='/".WPINC."/js/thickbox/thickbox.css?ver=20080613' type='text/css' media='all' />\n";
|
272 |
+
}
|
273 |
+
/**
|
274 |
+
* adds the thickbox style to header for commentluv settings page
|
275 |
+
* called by add_action('admin_print_styles-settings_page_commentluv-options
|
276 |
+
*/
|
277 |
+
function add_settings_page_style(){
|
278 |
+
wp_enqueue_style('thickbox');
|
279 |
+
}
|
280 |
+
/** admin_init
|
281 |
+
* This function registers the settings group
|
282 |
+
* it is called by add_action admin_init
|
283 |
+
* options in the options page will need to be named using $this->db_option[option]
|
284 |
+
*/
|
285 |
+
function admin_init(){
|
286 |
+
// whitelist options
|
287 |
+
register_setting( 'commentluv_options_group', $this->db_option ,array(&$this,'options_sanitize' ) );
|
288 |
+
$options = $this->get_options();
|
289 |
+
//if(isset($options['upgrade'])){
|
290 |
+
if(isset($options['upgrade']) && version_compare($options['upgrade'],$this->php_version($this->version),'>')){
|
291 |
+
add_action('admin_notices',array(&$this,'show_upgrade_notice'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
}
|
293 |
+
}
|
294 |
|
295 |
+
/** admin_menu
|
296 |
+
* This function adds a link to the settings page to the admin menu
|
297 |
+
* see http://codex.wordpress.org/Adding_Administration_Menus
|
298 |
+
* it is called by add_action admin_menu
|
299 |
+
*/
|
300 |
+
function admin_menu(){
|
301 |
+
if(is_multisite()){
|
302 |
+
$level = 'manage_options'; // for wpmu sub blog admins
|
303 |
+
} else {
|
304 |
+
$level = 'administrator'; // for single blog intalls
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
}
|
306 |
+
$menutitle = '<img src="' . $this->plugin_url . 'images/littleheart.gif" alt=""/> CommentLuv';
|
307 |
+
add_options_page ( 'CommentLuv settings', $menutitle, $level, $this->slug, array (&$this, 'options_page' ) );
|
308 |
+
}
|
309 |
+
/**
|
310 |
+
* ajax handler
|
311 |
+
* setup by add_action ( 'wp_ajax_removeluv'
|
312 |
+
* called when remove luv link is clicked in comments edit page
|
313 |
+
* with POST['action'] of removeluv, receives cid and _wpnonce
|
314 |
+
*/
|
315 |
+
function ajax_remove_luv(){
|
316 |
+
// check user is allowed to do this
|
317 |
+
$nonce=$_REQUEST['_wpnonce'];
|
318 |
+
$cid = $_REQUEST['cid'];
|
319 |
+
if (! wp_verify_nonce($nonce, 'removeluv'.$cid) ) die("Epic fail");
|
320 |
+
// delete meta if comment id sent with request
|
321 |
+
if($cid){
|
322 |
+
// get meta and set vars if exists
|
323 |
+
$cmeta =get_comment_meta($cid,'cl_data','true');
|
324 |
+
if($cmeta) extract($cmeta);
|
325 |
+
// delete it and call comluv to tell it what happened
|
326 |
+
if(delete_comment_meta($cid,'cl_data')){
|
327 |
+
// can call originator blog here maybe
|
328 |
+
// return the comment id and status code for js processing to hide luv
|
329 |
+
echo "$cid*200";
|
330 |
+
}
|
331 |
+
} else {
|
332 |
+
echo '0';
|
333 |
+
}
|
334 |
+
exit;
|
335 |
+
}
|
336 |
+
/**
|
337 |
+
* checks for a new version
|
338 |
+
* called by a cron action
|
339 |
+
*/
|
340 |
+
function check_version(){
|
341 |
+
//debugbreak();
|
342 |
+
$version = $this->php_version($this->version);
|
343 |
+
$options = $this->get_options();
|
344 |
+
$url = 'http://version.commentluv.com/';
|
345 |
+
$name = strip_tags(get_bloginfo('name'));
|
346 |
+
$description = strip_tags(get_bloginfo('description'));
|
347 |
+
$ioncube = extension_loaded('ionCube Loader')? 'yes' : 'no';
|
348 |
+
$numluv = $this->get_numluv();
|
349 |
+
$dofollow = $options['dofollow'];
|
350 |
+
$whogets = $options['whogets'];
|
351 |
+
$body = array('version'=>$version,'enabled'=>$options['enable'],'name'=>$name,'description'=>$description,'avatarmd5'=>md5(strtolower(get_bloginfo('admin_email'))),'numluv'=>$numluv,'dofollow'=>$dofollow,'whogets'=>$whogets,'ioncube'=>$ioncube);
|
352 |
+
$response = wp_remote_head($url,array('method'=>'POST','body'=>$body));
|
353 |
+
$latest = $this->php_version(wp_remote_retrieve_header($response,'version'));
|
354 |
+
$message = wp_remote_retrieve_header($response,'message');
|
355 |
+
if(version_compare($version,$latest,'<')){
|
356 |
+
$options['upgrade'] = $latest;
|
357 |
+
if($message){
|
358 |
+
$options['upgrade_message'] = apply_filters('kindergarten_html',$message);
|
359 |
+
}
|
360 |
+
update_option($this->db_option,$options);
|
361 |
+
}
|
362 |
+
}
|
363 |
+
/**
|
364 |
+
* called by add_action('comment_post
|
365 |
+
* runs just after comment has been saved to the database
|
366 |
+
* will save the luv link to comment meta if it exists
|
367 |
+
*
|
368 |
+
* @param int $id - id of the comment
|
369 |
+
* @param string $commentdata - status of comment
|
370 |
+
*/
|
371 |
+
function comment_posted($id,$commentdata){
|
372 |
+
if(isset($_POST['cl_post_url']) && $_POST['cl_post_url'] != '' && isset($_POST['cl_post_title']) && $_POST['cl_post_title'] != ''){
|
373 |
+
$title = strip_tags($_POST['cl_post_title']);
|
374 |
+
$link = esc_url($_POST['cl_post_url']);
|
375 |
$options = $this->get_options();
|
376 |
+
//debugbreak();
|
377 |
+
// check for spam or delete comment if no author url
|
378 |
+
// spam or delete comment if no author url depending on user settings
|
379 |
+
//(for logged out users only because logged in users have no commentdata->comment_author_url)
|
380 |
+
if(!is_user_logged_in()){
|
381 |
+
if($options['hide_link_no_url'] == 'spam' && $commentdata->comment_author_url ==''){
|
382 |
+
$commentdata->comment_approved = 'spam';
|
383 |
+
$update = wp_update_comment((array)$commentdata);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
}
|
385 |
+
if($options['hide_link_no_url'] == 'delete' && $commentdata->comment_author_url == ''){
|
386 |
+
wp_delete_comment($id);
|
387 |
+
return;
|
388 |
+
}
|
389 |
+
// check for matching comment
|
390 |
+
if(!isset($options['hide_link_no_url_match'])){
|
391 |
+
$options['hide_link_no_url_match'] = 'nothing';
|
392 |
+
}
|
393 |
+
$authorurlarr = parse_url($commentdata->comment_author_url);
|
394 |
+
$linkurlarr = parse_url($link);
|
395 |
+
if($options['hide_link_no_url_match'] != 'nothing'){
|
396 |
+
if($authorurlarr['host'] != $linkurlarr['host']){
|
397 |
+
// link has different domain
|
398 |
+
if($options['hide_link_no_url_match'] == 'spam'){
|
399 |
+
$commentdata->comment_approved = 'spam';
|
400 |
+
$update = wp_update_comment((array)$commentdata);
|
401 |
+
}
|
402 |
+
if($options['hide_link_no_url_match'] == 'delete'){
|
403 |
+
wp_delete_comment($id);
|
404 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
}
|
406 |
}
|
407 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
408 |
}
|
409 |
+
$prem = 'p' == $_POST['cl_prem'] ? 'p' : 'u';
|
410 |
+
$data = array('cl_post_title'=>$title,'cl_post_url'=>$link,'cl_prem'=>$prem);
|
411 |
+
add_comment_meta($id,'cl_data',$data,'true');
|
412 |
+
}
|
413 |
+
}
|
414 |
+
/**
|
415 |
+
* add my own recurrence schedule
|
416 |
+
* called by add_filter('cron_schedules
|
417 |
+
*
|
418 |
+
* @param mixed $schedules - the current schedules
|
419 |
+
*/
|
420 |
+
function cron_schedules($schedules){
|
421 |
+
$schedules['clfortnightly'] = array(
|
422 |
+
'interval' => 1209600,
|
423 |
+
'display' => __('Twice Monthly')
|
424 |
+
);
|
425 |
+
return $schedules;
|
426 |
+
}
|
427 |
+
/** runs when plugin is deactivated
|
428 |
+
* called by register_deactivation_hook
|
429 |
+
*
|
430 |
+
*/
|
431 |
+
function deactivation(){
|
432 |
+
wp_clear_scheduled_hook('clversion');
|
433 |
+
}
|
434 |
+
/**
|
435 |
+
* detect if request is from a commentluv useragent
|
436 |
+
* called by add_action('init
|
437 |
+
*
|
438 |
+
* ignore if user has set disable_detect in settings
|
439 |
+
*
|
440 |
+
* since 2.90.9.9 - add action for template redirect, we do the sending of the special feed there now
|
441 |
+
*/
|
442 |
+
function detect_useragent(){
|
443 |
+
$options = $this->get_options();
|
444 |
+
// dont do anything if detect is disabled
|
445 |
+
if(isset($_POST['version_check'])){
|
446 |
+
$this->check_version();
|
447 |
}
|
448 |
+
if(isset($options['disable_detect']) && $options['disable_detect'] == 'on'){
|
449 |
+
return;
|
450 |
+
}
|
451 |
+
// is this commentluv calling?
|
452 |
+
if (preg_match("/Commentluv/i", $_SERVER['HTTP_USER_AGENT'])){
|
453 |
+
$this->is_commentluv_request = true;
|
454 |
+
ob_start();
|
455 |
+
if(!isset($options['disable_detect'])){
|
456 |
+
remove_all_actions('wp_head');
|
457 |
+
remove_all_actions('wp_footer');
|
458 |
+
// prevent wordpress.com stats from adding stats script
|
459 |
+
global $wp_query;
|
460 |
+
$wp_query->is_feed = true;
|
461 |
+
// use own function to output feed
|
462 |
+
add_action('template_redirect',array(&$this,'send_feed_file'),1);
|
463 |
+
}
|
464 |
+
}
|
465 |
+
}
|
466 |
+
/**
|
467 |
+
* Called by add_fields or by manual insert
|
468 |
+
* used to show the badge and extra bits for holding the ajax drop down box
|
469 |
+
*
|
470 |
+
*/
|
471 |
+
function display_badge(){
|
472 |
+
//DebugBreak();
|
473 |
+
global $clbadgeshown;
|
474 |
+
$badges = array('default'=>'CL91_default.png','default_image'=>'CL91_default.png','white'=>'CL91_White.gif','black'=>'CL91_Black.gif');
|
475 |
+
$options = $this->get_options();
|
476 |
+
if($clbadgeshown == true){
|
477 |
+
return;
|
478 |
+
}
|
479 |
+
// link to commentluv?
|
480 |
+
$before = '';
|
481 |
+
$after = '';
|
482 |
+
// link
|
483 |
+
if(isset($options['link'])){
|
484 |
+
$before = '<a href="http://www.commentluv.com" target="_blank" title="'.__('CommentLuv is enabled',$this->plugin_domain).'">';
|
485 |
+
$after = '</a>';
|
486 |
+
}
|
487 |
+
// dropdown choice
|
488 |
+
if($options['badge_choice'] == 'drop_down'){
|
489 |
+
if($options['badge_type'] != 'none'){
|
490 |
+
$imgurl = $this->plugin_url.'images/'.$badges[$options['badge_type']];
|
491 |
}
|
492 |
+
}
|
493 |
+
// custom image
|
494 |
+
if($options['badge_choice'] == 'custom'){
|
495 |
+
if(isset($options['custom_image_url']) && $options['custom_image_url'] != ''){
|
496 |
+
if(!strstr($options['custom_image_url'],'http://')){
|
497 |
+
$imgurl = 'http://'.$options['custom_image_url'];
|
498 |
+
} else {
|
499 |
+
$imgurl = $options['custom_image_url'];
|
500 |
}
|
|
|
|
|
|
|
|
|
|
|
501 |
}
|
502 |
+
}
|
503 |
+
// create badge code (if not chosen 'none')
|
504 |
+
if($options['badge_choice'] == 'drop_down' && $options['badge_type'] == 'none'){
|
505 |
+
$badgecode = '';
|
506 |
+
} else {
|
507 |
+
if(!$imgurl){
|
508 |
+
$imgurl = $this->plugin_url.'images/'.$badges['default_image'];
|
509 |
+
}
|
510 |
+
$badgecode = $before.'<img alt="CommentLuv badge" src="'.$imgurl.'"/>'.$after;
|
511 |
+
}
|
512 |
+
// or using text
|
513 |
+
if($options['badge_choice'] == 'text'){
|
514 |
+
$badgecode = $before.$options['badge_text'].$after;
|
515 |
+
}
|
516 |
+
// default on
|
517 |
+
$default_on = '';
|
518 |
+
if($options['default_on'] == 'on'){
|
519 |
+
$default_on = ' checked="checked"';
|
520 |
+
if(is_user_logged_in() && current_user_can('manage_options')){
|
521 |
+
if($options['default_on_admin'] != 'on'){
|
522 |
+
$default_on = '';
|
523 |
}
|
524 |
}
|
525 |
+
}
|
526 |
+
// spit out code
|
527 |
+
echo '<div id="commentluv"><div id="cl_messages"></div><input type="checkbox" id="doluv" name="doluv"'.$default_on.' /><span id="mylastpost">'.$badgecode.'</span><span id="showmorespan"><img class="clarrow" id="showmore" src="'.$this->plugin_url.'images/down-arrow.gif" alt="'.__('Show more posts',$this->plugin_domain).'" title="'.__('Show more posts',$this->plugin_domain).'" style="display:none;"/></span></div><div id="lastposts" style="display:none;"></div>';
|
528 |
+
$clbadgeshown = true;
|
529 |
+
}
|
530 |
+
/**
|
531 |
+
* ajax handler.
|
532 |
+
* called by add_action('wp_ajax_(nopriv_)ajax
|
533 |
+
* handles all ajax requests, receives 'do' as POST var and calls relevant function
|
534 |
+
*
|
535 |
+
*/
|
536 |
+
function do_ajax(){
|
537 |
+
$oldchecknonce = $_POST['_ajax_nonce'];
|
538 |
+
$newchecknonce = preg_replace("/[^A-Za-z0-9 ]/", '', $oldchecknonce);
|
539 |
+
if($oldchecknonce != $newchecknonce){
|
540 |
+
die('error! nonce malformed');
|
541 |
+
}
|
542 |
+
switch($_POST['do']){
|
543 |
+
case 'fetch' :
|
544 |
+
$this->fetch_feed();
|
545 |
+
break;
|
546 |
+
case 'info' :
|
547 |
+
$this->do_info();
|
548 |
+
break;
|
549 |
+
case 'click' :
|
550 |
+
$this->do_click();
|
551 |
+
break;
|
552 |
|
|
|
553 |
}
|
554 |
+
}
|
555 |
+
/**
|
556 |
+
* called by do_ajax
|
557 |
+
* receives cid and nonce and cl_prem as POST vars
|
558 |
+
* stores the click in the comment meta
|
559 |
+
*/
|
560 |
+
function do_click(){
|
561 |
+
$cid = intval($_POST['cid']);
|
562 |
+
$nonce = $_POST['_ajax_nonce'];
|
563 |
+
$url = $_POST['url'];
|
564 |
+
if(!wp_verify_nonce($nonce,$cid)){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
565 |
exit;
|
566 |
}
|
567 |
+
$data = get_comment_meta($cid,'cl_data',true);
|
568 |
+
if(is_array($data)){
|
569 |
+
$data['clicks'] = $data['clicks'] + 1;
|
570 |
+
update_comment_meta($cid,'cl_data',$data);
|
571 |
+
}
|
572 |
+
if($_POST['cl_prem'] == 'true'){
|
573 |
+
$comment = get_commentdata($cid);
|
574 |
+
$refer = get_permalink($comment['comment_post_ID']);
|
575 |
+
// set blocking to false because no response required
|
576 |
+
$response = wp_remote_post($url,array('blocking'=>false,'body'=>array('cl_request'=>'click','refer'=>$refer,'version'=>$this->version)));
|
577 |
+
}
|
578 |
+
exit;
|
579 |
+
}
|
580 |
+
/**
|
581 |
+
* called by do_ajax
|
582 |
+
* receives cl_prem, url and cid as POST vars
|
583 |
+
* sends back json encoded string for the content of the panel
|
584 |
+
*/
|
585 |
+
function do_info(){
|
586 |
|
587 |
+
check_ajax_referer('info');
|
588 |
+
global $wpdb;
|
589 |
+
$options = $this->get_options();
|
590 |
+
$isreg = false;
|
591 |
+
$cid = intval($_POST['cid']);
|
592 |
+
$cl_prem = $_POST['cl_prem'];
|
593 |
+
$link = $_POST['link'];
|
594 |
+
// is registered user?
|
595 |
+
$email = get_comment_author_email($cid);
|
596 |
+
$user = get_user_by_email($email);
|
597 |
+
if($user){
|
598 |
+
$isreg = true;
|
599 |
+
}
|
600 |
+
// get comments and stats
|
601 |
+
$query = $wpdb->prepare('SELECT m.meta_value, c.comment_post_ID FROM '.$wpdb->comments.' c JOIN '.$wpdb->commentmeta.' m ON c.comment_ID = m.comment_ID WHERE c.comment_approved = 1 AND c.comment_author_email = %s AND m.meta_key = %s ORDER BY c.comment_ID DESC',$email,'cl_data');
|
602 |
+
$rows = $wpdb->get_results($query);
|
603 |
+
$num_comments = $wpdb->num_rows;
|
604 |
+
// get other comments and links left
|
605 |
+
$appeared_on = array();
|
606 |
+
$appeared_on_list = array();
|
607 |
+
$my_other_posts = array();
|
608 |
+
$my_other_posts_list = array();
|
609 |
|
610 |
+
if($rows){
|
611 |
+
foreach($rows as $row){
|
612 |
+
$data = unserialize($row->meta_value);
|
613 |
+
if(!in_array($data['cl_post_url'],$my_other_posts_list) && sizeof($my_other_posts) < 5){
|
614 |
+
$my_other_posts[] = '<a target="_blank" href="'.$data['cl_post_url'].'">'.esc_js(substr($data['cl_post_title'],0,60)).'</a>';
|
615 |
+
$my_other_posts_list[] = $data['cl_post_url'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
616 |
}
|
617 |
+
if(!in_array($row->comment_post_ID,$appeared_on_list) && sizeof($appeared_on) < 5){
|
618 |
+
$appeared_on[] = '<a href="'.get_permalink($row->comment_post_ID).'">'.substr(get_the_title($row->comment_post_ID),0,60).'</a>';
|
619 |
+
$appeared_on_list[] = $row->comment_post_ID;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
620 |
}
|
621 |
+
// stop if both lists at 5
|
622 |
+
if(count($appeared_on) >= 5 && count($my_other_posts) >= 5){
|
623 |
+
break;
|
|
|
|
|
624 |
}
|
625 |
+
}
|
626 |
+
}
|
627 |
+
if(empty($appeared_on)){
|
628 |
+
$appeared_on[] = __('I have only commented on this post',$this->plugin_domain);
|
629 |
+
}
|
630 |
+
if(empty($my_other_posts)){
|
631 |
+
$my_other_posts[] = '<a>'.__('If I had made more comments on this site, you would see more of my other posts here',$this->plugin_domain).'</a>';
|
632 |
+
}
|
633 |
+
// get click count on local site
|
634 |
+
$data = get_comment_meta($cid,'cl_data',true);
|
635 |
+
$clickcount = $data['clicks'] ? $data['clicks'] : 0;
|
636 |
+
//DebugBreak();
|
637 |
+
// prem member, try remote fetch of info if not registered on this blog
|
638 |
+
if($cl_prem == 'p' && $isreg == false){
|
639 |
+
$response = wp_remote_post($link,array('body'=>array('cl_request'=>'info','version'=>$this->version,'clickcount'=>$clickcount,'num_comments'=>$num_comments,'appeared_on'=>$appeared_on)));
|
640 |
+
$enabled = wp_remote_retrieve_header($response,'cl_info');
|
641 |
+
if($enabled == 'enabled'){
|
642 |
+
$panel = apply_filters('kindergarten_html',wp_remote_retrieve_body($response));
|
643 |
$json = json_encode(array('panel'=>$panel));
|
644 |
header ( "Content-Type: application/x-javascript; " );
|
645 |
echo $json;
|
646 |
exit;
|
647 |
+
} else {
|
648 |
+
$cl_prem = 'u';
|
649 |
}
|
650 |
+
}
|
651 |
+
// show registered members panel
|
652 |
+
if($isreg){
|
653 |
+
// get users info
|
654 |
+
$bio = $user->description;
|
655 |
+
if($bio == ''){
|
656 |
+
$bio = __('User has not saved a description in their profile page',$this->plugin_domain);
|
657 |
+
}
|
658 |
+
$username = $user->display_name;
|
659 |
+
if(is_multisite()){
|
660 |
+
$can = 'manage_options';
|
661 |
+
} else {
|
662 |
+
$can = 'administrator';
|
663 |
+
}
|
664 |
+
// find if user has cap, need to create new user object and use ->has_cap
|
665 |
+
// from wp 3.1, you can use if(user_can($user,$cap))
|
666 |
+
$user = new WP_User($user->ID);
|
667 |
+
if($user->has_cap($can)){
|
668 |
+
$reg_member = __('is the administrator of this site',$this->plugin_domain);
|
669 |
+
} else {
|
670 |
+
$reg_member = __('is a registered member of my site',$this->plugin_domain);
|
671 |
+
}
|
672 |
+
$gravatar = '<img src="http://www.gravatar.com/avatar/' . md5 ( strtolower($email) ) . '.jpg" alt="' . $username . '" align="left" />';
|
673 |
+
$panel = $gravatar . "<p class=\"cl_title\"><span class=\"cl_username\">$username</span> ".$reg_member."</p><p class=\"cl_bio\">$bio</p><p class=\"cl_clicks\"> <span class=\"cl_clicks_count\">$clickcount</span> ".__('Clicks on this link on this comment',$this->plugin_domain)."</p><p class=\"cl_links\">".$num_comments.' '.__('approved comments on this site',$this->plugin_domain).'<br>'.__('Some other posts I have commented on',$this->plugin_domain)."</p><p class=\"cl_links_list\">".implode('<br>',$appeared_on)."</p><p class=\"cl_posts\">".__('Some of my other posts',$this->plugin_domain)."</p><p class=\"cl_posts_list\">".implode('<br>',$my_other_posts)."</p>";
|
674 |
$json = json_encode(array('panel'=>$panel));
|
675 |
header ( "Content-Type: application/x-javascript; " );
|
676 |
echo $json;
|
677 |
exit;
|
678 |
}
|
679 |
+
// show panel for everyone else
|
680 |
+
$comment = get_comment($cid);
|
681 |
+
$msg = '';
|
682 |
+
$bio= get_comment_author_url($cid);
|
683 |
+
$name = get_comment_author($cid);
|
684 |
+
$gravatar = '<img src="http://www.gravatar.com/avatar/' . md5 ( strtolower($email) ) . '.jpg" alt="' . $name . '" align="left" />';
|
685 |
+
if(get_option('users_can_register') && $options['whogets'] == 'registered'){
|
686 |
+
$msg = __('has not registered on this site',$this->plugin_domain);
|
687 |
+
$bio = $options['unreg_user_text_panel'];
|
688 |
+
}
|
689 |
+
$panel = $gravatar . "<p class=\"cl_title\">
|
690 |
+
<span class=\"cl_username\">".$comment->comment_author."</span> ".$msg."</p>
|
691 |
+
<p class=\"cl_bio\">".$bio."</p>
|
692 |
+
<p class=\"cl_clicks\"> <span class=\"cl_clicks_count\">$clickcount</span> ".__('Clicks on this link on this comment',$this->plugin_domain)."</p>
|
693 |
+
<p class=\"cl_links\">".$num_comments.' '.__('approved comments on this site',$this->plugin_domain).
|
694 |
+
'<br>'.__('Some other posts I have commented on',$this->plugin_domain)."</p>
|
695 |
+
<p class=\"cl_links_list\">".implode('<br>',$appeared_on)."</p>";
|
696 |
+
// dont show other links for non registered user to entice them to register
|
697 |
+
//<p class=\"cl_posts\">".__('Some of my other posts',$this->plugin_domain)."</p>
|
698 |
+
//<p class=\"cl_posts_list\">".implode('<br>',$my_other_posts)."</p>";
|
699 |
+
$json = json_encode(array('panel'=>$panel));
|
700 |
+
header ( "Content-Type: application/x-javascript; " );
|
701 |
+
echo $json;
|
702 |
+
exit;
|
703 |
+
}
|
704 |
+
/**
|
705 |
+
* called by add_filter('comments_array
|
706 |
+
* adds the link to the comments that are to be displayed
|
707 |
+
* @param mixed $commentarray
|
708 |
+
*/
|
709 |
+
function do_shortcode($commentarray){
|
710 |
+
$isadminpage = false;
|
711 |
+
$options= $this->get_options();
|
712 |
+
if(!is_array($commentarray)){
|
713 |
+
// if it's an array then it was called by comments_array filter,
|
714 |
+
// otherwise it was called by comment_content (admin screen)
|
715 |
+
// has it been done before?
|
716 |
+
if(strpos($commentarray,'class="cluv"')){
|
717 |
+
return $commentarray;
|
718 |
+
}
|
719 |
+
// make a fake array of 1 object so below treats the comment_content filter nicely for admin screen
|
720 |
+
$temparray = array('comment_ID'=>get_comment_ID(),'comment_content'=>$commentarray,'comment_author'=>get_comment_author(), 'comment_author_email'=>get_comment_author_email());
|
721 |
+
$tempobject = (object) $temparray;
|
722 |
+
$commentarray = array($tempobject);
|
723 |
+
$isadminpage = true;
|
724 |
+
}
|
725 |
+
// add link to comments (need to do it this way so thesis works with commentluv links, thesis wont use comment_text filter but it does get an array of comments)
|
726 |
+
$new_commentarray = array();
|
727 |
+
foreach($commentarray as $comment){
|
728 |
+
$data = get_comment_meta($comment->comment_ID,'cl_data','true');
|
729 |
+
$commentcontent = $comment->comment_content;
|
730 |
+
// luvlink added?
|
731 |
+
if($data && is_array($data)){
|
732 |
+
if($data['cl_post_url'] != '' && $data['cl_post_title'] != ''){
|
733 |
+
// luvlink was saved to meta, dofollow the link?
|
734 |
+
$nofollow = ' rel="nofollow"';
|
735 |
+
$isreg = get_user_by_email($comment->comment_author_email);
|
736 |
+
if($options['dofollow'] == 'everybody'){
|
737 |
+
$nofollow = '';
|
738 |
+
} elseif ($options['dofollow'] == 'registered' && $isreg){
|
739 |
+
$nofollow = '';
|
740 |
+
}
|
741 |
+
// construct link
|
742 |
+
$pclass = $data['cl_prem'] == 'p' ? ' p' : '';
|
743 |
+
$ajaxnonce = wp_create_nonce($comment->comment_ID);
|
744 |
+
$class = ' class="'.$ajaxnonce.' '.$comment->comment_ID.$pclass.'"';
|
745 |
+
$luvlink = '<a'.$class.$nofollow.' href="'.$data['cl_post_url'].'">'.$data['cl_post_title'].'</a>';
|
746 |
+
$search = array ('[name]', '[lastpost]','[type]' );
|
747 |
+
$replace = array ($comment->comment_author, $luvlink,'blog post' );
|
748 |
+
$prepend_text = $options ['comment_text'];
|
749 |
+
$inserted = str_replace ( $search, $replace, $prepend_text );
|
750 |
+
// check if author has a url. do not add the link if user has set to hide links for comments with no url
|
751 |
+
$authurl = $comment->comment_author_url;
|
752 |
+
$showlink = true;
|
753 |
+
if($authurl == '' && isset($options['hide_link_no_url']) && $options['hide_link_no_url'] == 'on'){
|
754 |
+
$showlink = false;
|
755 |
+
}
|
756 |
+
// check link domain matches author url domain
|
757 |
+
if(!isset($options['hide_link_no_url_match'])){
|
758 |
+
$options['hide_link_no_url_match'] = 'nothing';
|
759 |
+
}
|
760 |
+
$authorurlarr = parse_url($authurl);
|
761 |
+
$linkurlarr = parse_url($data['cl_post_url']);
|
762 |
+
if($options['hide_link_no_url_match'] != 'nothing'){
|
763 |
+
if($authorurlarr['host'] != $linkurlarr['host']){
|
764 |
+
// link has different domain
|
765 |
+
if($options['hide_link_no_url_match'] == 'on'){
|
766 |
+
$showlink = false;
|
767 |
}
|
|
|
|
|
|
|
|
|
768 |
}
|
769 |
+
}
|
770 |
+
if($showlink){
|
771 |
+
// construct string to be added to comment
|
772 |
+
$commentcontent .= "\n<span class=\"cluv\">$inserted";
|
773 |
+
// prepare heart icon if infopanel is on
|
774 |
+
$hearticon = '';
|
775 |
+
if($data['cl_prem'] == 'p' || $isreg) {
|
776 |
+
// use PLUS heart for members
|
777 |
+
$hearticon = 'plus';
|
778 |
+
}
|
779 |
+
if ($options ['infopanel'] == 'on') {
|
780 |
+
$commentcontent .= '<span class="heart_tip_box"><img class="heart_tip '.$data['cl_prem'].' '.$comment->comment_ID.'" alt="My Profile" style="border:0" width="16" height="14" src="' . $this->plugin_url . 'images/littleheart'.$hearticon.'.gif"/></span>';
|
781 |
+
}
|
782 |
+
$commentcontent.= '</span>';
|
783 |
}
|
784 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
785 |
}
|
786 |
+
// store new content in this comments comment_content cell
|
787 |
+
$comment->comment_content = $commentcontent;
|
788 |
+
// fill new array with this comment
|
789 |
+
$new_commentarray[] = $comment;
|
790 |
}
|
791 |
+
// admin page or public page?
|
792 |
+
if($isadminpage){
|
793 |
+
// is being called by comment_text filter so expecting just content
|
794 |
+
return $commentcontent;
|
795 |
+
} else {
|
796 |
+
// called from comments_array filter so expecting array of objects
|
797 |
+
return $new_commentarray;
|
798 |
+
}
|
799 |
+
}
|
800 |
+
/**
|
801 |
+
* called by do_ajax())
|
802 |
+
* takes action when ajax request is made with URL from the comment form
|
803 |
+
* send back 1 or 10 last posts depending on rules
|
804 |
+
*/
|
805 |
+
function fetch_feed(){
|
806 |
+
// check nonce
|
807 |
+
//debugbreak();
|
808 |
+
$checknonce = check_ajax_referer('fetch',false,false);
|
809 |
+
if(!$checknonce){
|
810 |
+
die(' error! not authorized '.strip_tags($_REQUEST['_ajax_nonce']));
|
811 |
+
}
|
812 |
+
if(!$_POST['url']){
|
813 |
+
die('no url');
|
814 |
+
}
|
815 |
+
if(!defined('DOING_AJAX')){
|
816 |
+
define('DOING_AJAX',true);
|
817 |
+
}
|
818 |
+
// try to prevent deprecated notices
|
819 |
+
@ini_set('display_errors',0);
|
820 |
+
@error_reporting(0);
|
821 |
+
include_once(ABSPATH.WPINC.'/class-simplepie.php');
|
822 |
+
$options = $this->get_options();
|
823 |
+
$num = 1;
|
824 |
+
$url = esc_url($_POST['url']);
|
825 |
+
$orig_url = $url;
|
826 |
+
// add trailing slash (can help with some blogs)
|
827 |
+
if(!strpos($url,'?')){
|
828 |
+
$url = trailingslashit($url);
|
829 |
+
}
|
830 |
+
// fetch 10 last posts?
|
831 |
+
if((is_user_logged_in() && $options['whogets'] == 'registered') || (!is_user_logged_in() && $options['whogets'] == 'everybody')){
|
832 |
+
$num = 10;
|
833 |
+
} elseif($options['whogets'] == 'everybody') {
|
834 |
+
$num = 10;
|
835 |
+
} elseif(current_user_can('manage_options')){
|
836 |
+
$num = 10;
|
837 |
+
}
|
838 |
+
// check if request is for the blog we're on
|
839 |
+
if(strstr($url, home_url())){
|
840 |
+
//DebugBreak();
|
841 |
+
$posts = get_posts(array('numberposts'=>10));
|
842 |
+
$return = array();
|
843 |
+
$error = '';
|
844 |
+
if($posts){
|
845 |
+
foreach($posts as $post){
|
846 |
+
$return[] = array('type'=>'blog','title'=>htmlspecialchars_decode(strip_tags($post->post_title)),'link'=>get_permalink($post->ID),'p'=>'u');
|
847 |
}
|
848 |
+
} else {
|
849 |
+
$error = __('Could not get posts for home blog',$this->plugin_domain);
|
|
|
|
|
850 |
}
|
851 |
+
// check for admin only notices to add
|
852 |
+
$canreg = get_option('users_can_register');
|
853 |
+
$whogets = $options['whogets'];
|
854 |
+
if(!$canreg && $whogets == 'registered'){
|
855 |
+
$return[] = array('type'=>'message','title'=>__('Warning! You have set to show 10 posts for registered users but you have not enabled user registrations on your site. You should change the operational settings in the CommentLuv settings page to show 10 posts for everyone or enable user registrations',$this->plugin_domain),'link'=>'');
|
856 |
}
|
857 |
+
$response = json_encode(array('error'=>$error,'items'=>$return));
|
858 |
+
header( "Content-Type: application/json" );
|
859 |
+
echo $response;
|
860 |
+
exit;
|
861 |
+
}
|
862 |
+
// get simple pie ready
|
863 |
+
$rss = new SimplePie();
|
864 |
+
if(!$rss){
|
865 |
+
die(' error! no simplepie');
|
866 |
+
}
|
867 |
+
$rss->set_useragent('Commentluv /'.$this->version.' (Feed Parser; http://www.commentluv.com; Allow like Gecko) Build/20110502' );
|
868 |
+
$rss->set_feed_url ( add_query_arg(array('commentluv'=>'true'),$url) );
|
869 |
+
$rss->enable_cache ( FALSE );
|
870 |
+
// fetch the feed
|
871 |
+
$rss->init();
|
872 |
+
$su = $rss->subscribe_url();
|
873 |
+
$ferror = $rss->error();
|
874 |
+
// try a fall back and add /?feed=rss2 to the end of url if the found subscribe url hasn't already got it
|
875 |
+
// also try known blogspot feed location if this is a blogspot url
|
876 |
+
if($ferror || strstr($ferror,'could not be found') && !strstr($su,'feed')){
|
877 |
+
unset($rss);
|
878 |
+
$rss = new SimplePie();
|
879 |
$rss->set_useragent('Commentluv /'.$this->version.' (Feed Parser; http://www.commentluv.com; Allow like Gecko) Build/20110502' );
|
|
|
880 |
$rss->enable_cache ( FALSE );
|
881 |
+
// construct alternate feed url
|
882 |
+
if(strstr($url,'blogspot')){
|
883 |
+
$url = trailingslashit($url).'feeds/posts/default/';
|
884 |
+
} else {
|
885 |
+
$url = add_query_arg(array('feed'=>'atom'),$url);
|
886 |
+
}
|
887 |
+
$rss->set_feed_url($url);
|
888 |
$rss->init();
|
|
|
889 |
$ferror = $rss->error();
|
890 |
+
if($ferror || stripos($ferror,'invalid')){
|
891 |
+
$suburl = $rss->subscribe_url() ? $rss->subscribe_url() : $orig_url;
|
|
|
892 |
unset($rss);
|
893 |
$rss = new SimplePie();
|
894 |
$rss->set_useragent('Commentluv /'.$this->version.' (Feed Parser; http://www.commentluv.com; Allow like Gecko) Build/20110502' );
|
895 |
+
$rss->enable_cache ( FALSE );
|
896 |
+
$rss->set_feed_url($orig_url);
|
|
|
|
|
|
|
|
|
|
|
|
|
897 |
$rss->init();
|
898 |
$ferror = $rss->error();
|
899 |
+
// go back to original URL if error persisted
|
900 |
+
if(stripos($ferror,'invalid')){
|
901 |
+
//get raw file to show any errors
|
902 |
+
@include_once(ABSPATH.WPINC.'/SimplePie/File.php');
|
903 |
+
if(class_exists('SimplePie_File')){
|
904 |
+
$rawfile = new SimplePie_File($suburl, $rss->timeout, 5, null, $rss->useragent, $rss->force_fsockopen);
|
905 |
+
} elseif (class_exists($rss->file_class)){
|
906 |
+
$rawfile = new $rss->file_class($suburl, $rss->timeout, 5, null, $rss->useragent, $rss->force_fsockopen);
|
907 |
+
}
|
908 |
+
if(isset($rawfile->body)){
|
909 |
+
$rawfile = $rawfile->body;
|
910 |
+
} else {
|
911 |
+
$rawfile = __('Raw file could not be found',$this->plugin_domain);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
912 |
}
|
913 |
}
|
914 |
}
|
915 |
+
}
|
916 |
+
$rss->handle_content_type();
|
917 |
+
$gen = $rss->get_channel_tags('','generator');
|
918 |
+
$prem_msg = $rss->get_channel_tags('','prem_msg');
|
919 |
+
$g = $num;
|
920 |
+
$p = 'u';
|
921 |
+
$meta = array();
|
922 |
+
//DebugBreak();
|
923 |
+
if($gen && strstr($gen[0]['data'],'commentluv')){
|
924 |
+
$generator = $gen[0]['data'];
|
925 |
+
$meta['generator'] = $generator;
|
926 |
+
$pos=stripos($generator,'v=');
|
927 |
+
if(substr($generator,$pos+2,1)=='3'){
|
928 |
+
$g=15;
|
929 |
+
$p='p';
|
|
|
|
|
|
|
930 |
}
|
931 |
+
}
|
932 |
+
if($prem_msg){
|
933 |
+
$prem_msg = $prem_msg[0]['data'];
|
934 |
+
}
|
935 |
+
//DebugBreak();
|
936 |
+
$error = $rss->error();
|
937 |
+
$meta['used_feed'] = $rss->subscribe_url();
|
938 |
+
//DebugBreak();
|
939 |
+
// no error, construct return json
|
940 |
+
if(!$error){
|
941 |
|
942 |
+
$arr = array();
|
943 |
|
944 |
+
// save meta
|
945 |
+
$meta['used_feed'] = $rss->subscribe_url ();
|
946 |
|
947 |
+
$feed_items = $rss->get_items();
|
948 |
+
foreach($feed_items as $item){
|
949 |
+
//debugbreak();
|
950 |
+
$type = 'blog';
|
951 |
+
$itemtags = $item->get_item_tags('','type');
|
952 |
+
if($itemtags){
|
953 |
+
$type = $itemtags[0]['data'];
|
|
|
|
|
|
|
|
|
|
|
|
|
954 |
}
|
955 |
+
$arr[] = array('type'=>$type,'title'=>htmlspecialchars_decode(strip_tags($item->get_title())),'link'=>$item->get_permalink(),'p'=>$p);
|
956 |
+
$g--;
|
957 |
+
if($g < 1){
|
958 |
+
break;
|
959 |
+
}
|
960 |
+
}
|
961 |
+
// add message to unregistered user if set
|
962 |
+
if(!is_user_logged_in() && $options['unreg_user_text'] && $options['whogets'] != 'everybody' && $p=='u'){
|
963 |
+
if(get_option('users_can_register')){
|
964 |
+
$arr[] = array('type'=>'message','title'=>$options['unreg_user_text'],'link'=>'');
|
965 |
+
if(!strstr($options['unreg_user_text'],'action=register')){
|
966 |
+
$register_link = apply_filters('register','<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>');
|
967 |
+
$arr[] = array('type'=>'message','title'=>$register_link,'link'=>'');
|
968 |
}
|
969 |
}
|
970 |
+
if($options['whogets'] == 'registered' && get_option('users_can_regsiter')){
|
971 |
+
$arr[] = array('type'=>'message','title'=>__('If you are registered, you need to log in to get 10 posts to choose from',$this->plugin_domain),'link'=>'');
|
972 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
973 |
}
|
974 |
+
if($prem_msg){
|
975 |
+
$arr[] = array('type'=>'alert','title'=>$prem_msg,'link'=>'');
|
|
|
|
|
|
|
976 |
}
|
977 |
+
$response = json_encode(array('error'=>'','items'=>$arr,'meta'=>$meta));
|
978 |
+
} else {
|
979 |
+
// had an error trying to read the feed
|
980 |
+
$response = json_encode(array('error'=>$error,'meta'=>$meta,'rawfile'=>htmlspecialchars($rawfile)));
|
981 |
+
}
|
982 |
+
unset($rss);
|
983 |
+
header( "Content-Type: application/json" );
|
984 |
+
echo $response;
|
985 |
+
exit;
|
986 |
+
}
|
987 |
+
/**
|
988 |
+
* find number of approved comments in the past 14 days to have a commentluv link
|
989 |
+
* called in check_version
|
990 |
+
* since 2.90.8
|
991 |
+
* @return int
|
992 |
+
*/
|
993 |
+
function get_numluv(){
|
994 |
+
global $wpdb;
|
995 |
+
$query = $wpdb->prepare('SELECT count(*) FROM '.$wpdb->commentmeta.' m JOIN '.$wpdb->comments.' c ON m.comment_id = c.comment_ID WHERE m.meta_key = %s AND c.comment_approved = %s AND c.comment_date > NOW() - INTERVAL 14 DAY','cl_data','1');
|
996 |
+
return intval($wpdb->get_var($query));
|
997 |
+
}
|
998 |
+
/** get_options
|
999 |
+
* This function sets default options and handles a reset to default options
|
1000 |
+
* @param string $reset = 'no' - whether to return default settings
|
1001 |
+
* return array
|
1002 |
+
*/
|
1003 |
+
function get_options($reset = 'no') {
|
1004 |
+
// see if we offer registration incentive
|
1005 |
+
$register_link = '';
|
1006 |
+
if(get_option('users_can_register')){
|
1007 |
+
$register_link = apply_filters('register','<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>');
|
1008 |
+
}
|
1009 |
+
// default values
|
1010 |
+
$this->handle_load_domain ();
|
1011 |
+
$default = array ('version'=>$this->version,'enable'=>'yes','enable_for'=>'both', 'default_on' => 'on', 'default_on_admin'=>'on',
|
1012 |
+
'badge_choice' => 'drop_down', 'badge_type'=>'default', 'link'=>'off','infopanel'=>'on', 'infoback'=>'white', 'infotext'=>'black',
|
1013 |
+
'comment_text'=>'[name] '.__('recently posted',$this->plugin_domain).'...[lastpost]', 'whogets'=>'registered', 'dofollow' => 'registered',
|
1014 |
+
'unreg_user_text'=>__('If you register as a user on my site, you can get your 10 most recent blog posts to choose from in this box.',$this->plugin_domain).' '.$register_link,
|
1015 |
+
'unreg_user_text_panel'=>__('If this user had registered to my site then they could get 10 last posts to choose from when they comment and you would be able to see a list of their recent posts in this panel',$this->plugin_domain),
|
1016 |
+
'template_insert'=>'','minifying'=>'','api_url'=>admin_url('admin-ajax.php'),'author_name'=>'author','email_name'=>'email','url_name'=>'url','comment_name'=>'comment',
|
1017 |
+
'hide_link_no_url'=>'nothing','hide_link_no_url_match'=>'nothing');
|
1018 |
+
$options = get_option ( $this->db_option, $default);
|
1019 |
+
// return the options
|
1020 |
+
if($reset == 'yes'){
|
1021 |
+
return $default;
|
1022 |
+
}
|
1023 |
+
if(!$options['api_url']){
|
1024 |
+
$options['api_url'] = admin_url('admin-ajax.php');
|
1025 |
+
}
|
1026 |
+
if(!$options['enable']){
|
1027 |
+
$options['enable'] = 'yes';
|
1028 |
+
}
|
1029 |
|
1030 |
+
return $options;
|
1031 |
+
}
|
1032 |
+
/** handle_load_domain
|
1033 |
+
* This function loads the localization files required for translations
|
1034 |
+
* It expects there to be a folder called /lang/ in the plugin directory
|
1035 |
+
* that has all the .mo files
|
1036 |
+
*/
|
1037 |
+
function handle_load_domain() {
|
1038 |
+
// get current language
|
1039 |
+
$locale = get_locale ();
|
1040 |
+
// locate translation file
|
1041 |
+
$mofile = WP_PLUGIN_DIR . '/' . plugin_basename ( dirname ( __FILE__ ) ) . '/lang/' . $this->plugin_domain . '-' . $locale . '.mo';
|
1042 |
+
// load translation
|
1043 |
+
load_textdomain ( $this->plugin_domain, $mofile );
|
1044 |
+
}
|
1045 |
+
/** init
|
1046 |
+
* This function registers styles and scripts
|
1047 |
+
*/
|
1048 |
+
function init(){
|
1049 |
+
wp_register_style( 'commentluv_style',$this->plugin_url.'css/commentluv.css' , $this->version);
|
1050 |
+
wp_register_script( 'commentluv_script', $this->plugin_url.'js/commentluv.js',array('jquery'),$this->version );
|
1051 |
+
}
|
1052 |
+
/** install
|
1053 |
+
* This function is called when the plugin activation hook is fired when
|
1054 |
+
* the plugin is first activated or when it is auto updated via admin.
|
1055 |
+
* use it to make any changes needed for updated version or to add/check
|
1056 |
+
* new database tables on first install.
|
1057 |
+
*/
|
1058 |
+
function install(){
|
1059 |
+
$options = $this->get_options();
|
1060 |
+
if(!$installed_version = get_option('cl_version')){
|
1061 |
+
// no installed version yet, set to version that was before big change
|
1062 |
+
$installed_version = 2.8;
|
1063 |
+
} else {
|
1064 |
+
// convert existing version to php type version number
|
1065 |
+
$installed_version = $this->php_version($installed_version);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1066 |
}
|
1067 |
+
// for version before 2.9
|
1068 |
+
if(version_compare($installed_version,'2.9','<')){
|
1069 |
+
// make any changes to this new versions options if needed and update
|
1070 |
+
update_option($this->db_option,$this->get_options('yes'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1071 |
}
|
1072 |
+
// new addition to technical settings after 2.90.1 release
|
1073 |
+
if(version_compare($installed_version,'2.9.0.1','<')){
|
1074 |
+
$options['api_url'] = admin_url('admin-ajax.php');
|
1075 |
+
$options['enable'] = 'yes';
|
1076 |
+
update_option($this->db_option,$options);
|
1077 |
+
}
|
1078 |
+
// update cl_version in db
|
1079 |
+
if($this->php_version($this->version) != $installed_version){
|
1080 |
+
update_option('cl_version',$this->version);
|
1081 |
+
}
|
1082 |
+
// has the comment meta table?
|
1083 |
+
global $wpdb;
|
1084 |
+
$query = $wpdb->prepare("SHOW tables LIKE %s",$wpdb->commentmeta);
|
1085 |
+
$dbtable = $wpdb->get_var($query);
|
1086 |
+
//$o['dbtable'] = $dbtable;
|
1087 |
+
if(!$dbtable){
|
1088 |
+
add_action('admin_notices',create_function('','echo "<div class=\"error\">'.__('Your Wordpress install is missing the <strong>wp_commentmeta</strong> table!',$pd).'<br>'.__(' CommentLuv cannot work without this table please see this wordpress forum post to learn how to add one ->',$pd).'<a target=\"_blank\" href=\"http://wordpress.org/support/topic/wp_commentmeta-table-a39xxxx2_blogwp_commentmeta-doesnt-exist?replies=7#post-1378281\">'.__('Missing wp_commentmeta table',$pd).'</a></div>";'));
|
1089 |
+
}
|
1090 |
+
}
|
1091 |
+
/**
|
1092 |
+
* helper function called by mulitple functions
|
1093 |
+
* used to determine if commentluv is enabled
|
1094 |
+
*/
|
1095 |
+
function is_enabled(){
|
1096 |
+
$options = $this->get_options();
|
1097 |
+
// see if we need to add here or not
|
1098 |
+
if(($options['enable_for'] == 'posts' && is_page()) || ($options['enable_for'] == 'pages' && !is_page())){
|
1099 |
+
return false;
|
1100 |
+
}
|
1101 |
+
if($options['enable'] != 'yes'){
|
1102 |
+
return false;
|
1103 |
+
}
|
1104 |
+
return true;
|
1105 |
+
}
|
1106 |
+
/**
|
1107 |
+
* called by apply_filter('kindergarten_html
|
1108 |
+
* Used to clean $input to only allow a kiddy set of html tags
|
1109 |
+
*
|
1110 |
+
* @param string $input - the string to be cleaned
|
1111 |
+
* @return string
|
1112 |
+
*/
|
1113 |
+
function kindergarten_html($input){
|
1114 |
+
$allowedtags = array(
|
1115 |
+
'h1' => array(),
|
1116 |
+
'br' => array(),
|
1117 |
+
'a' => array('href' => array(),'title' => array(),'rel' => array(),'target'=>array(), 'class'=>array()),
|
1118 |
+
'small' =>array(),
|
1119 |
+
'p' =>array( 'class'=>array()),
|
1120 |
+
'strong' => array(),
|
1121 |
+
'img' => array('src' => array(),'alt' => array(),'width' => array(),'height' => array(),'align'=> array()),
|
1122 |
+
'span' => array('class'=>array())
|
1123 |
+
);
|
1124 |
+
return wp_kses($input,$allowedtags);
|
1125 |
+
}
|
1126 |
+
/**
|
1127 |
+
* Ajax handler for the subscribe button on the settings page.
|
1128 |
+
* called by add_action ( 'wp_ajax_notify_signup'
|
1129 |
+
*/
|
1130 |
+
function notify_signup(){
|
1131 |
+
//DebugBreak();
|
1132 |
+
global $current_user;
|
1133 |
+
$email = $current_user->user_email;
|
1134 |
+
$firstname = $current_user->first_name;
|
1135 |
+
if(!$firstname){
|
1136 |
+
$firstname = $current_user->user_nicename;
|
1137 |
+
}
|
1138 |
+
$message = "\n Email: ".$email."\n\n Name: ".$firstname."\n\n Meta: settings_page_289"."\n\n";
|
1139 |
+
$to = 'cl_notify29@aweber.com';
|
1140 |
+
$headers = 'From: '.$firstname.' <'.$email.'>'."\r\n\\";
|
1141 |
+
$mail = wp_mail($to,'cl_notify',$message,$headers);
|
1142 |
+
if($mail === true){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1143 |
$options = $this->get_options();
|
1144 |
+
$options['subscribed'] = true;
|
1145 |
+
update_option($this->db_option,$options);
|
1146 |
+
}
|
1147 |
+
$return = array('success'=>$mail,'email'=>$email);
|
1148 |
+
// return response
|
1149 |
+
$response = json_encode($return);
|
1150 |
+
// response output
|
1151 |
+
header( "Content-Type: application/json" );
|
1152 |
+
echo $response;
|
1153 |
+
// IMPORTANT: don't forget to "exit"
|
1154 |
+
exit;
|
1155 |
+
}
|
1156 |
+
/** options_sanitize
|
1157 |
+
* This is the callback function for when the settings get saved, use it to sanitize options
|
1158 |
+
* it is called by the callback setting of register_setting in admin_init
|
1159 |
+
* @param mixed $options - the options that were POST'ed
|
1160 |
+
* return mixed $options
|
1161 |
+
*/
|
1162 |
+
function options_sanitize($options){
|
1163 |
+
//DebugBreak();
|
1164 |
+
$old_options = $this->get_options();
|
1165 |
+
// if not enabled, only save that so other settings remain unchanged
|
1166 |
+
if($options['enable'] == 'no'){
|
1167 |
+
$old_options['enable'] = 'no';
|
1168 |
+
return $old_options;
|
1169 |
+
}
|
1170 |
+
// check for reset
|
1171 |
+
if(isset($options['reset'])){
|
1172 |
+
return $this->get_options('yes');
|
1173 |
+
}
|
1174 |
+
// if on multisite and this isnt super admin saving,
|
1175 |
+
// only allow kindergarten html.
|
1176 |
+
if(is_multisite() && !is_super_admin()){
|
1177 |
+
foreach($options as $key => $option){
|
1178 |
+
$options[$key] = apply_filters('kindergarten_html',$option);
|
1179 |
}
|
1180 |
+
}
|
1181 |
+
// add error notices if any
|
1182 |
+
$canreg = get_option('users_can_register');
|
1183 |
+
if($options['whogets']=='registered' && !$canreg){
|
1184 |
+
add_settings_error('whogets','whogets',__('Warning! You have set to show 10 posts for registered users but you have not enabled user registrations on your site. You should change the operational settings in the CommentLuv settings page to show 10 posts for everyone or enable user registrations',$this->plugin_domain),'error');
|
1185 |
+
}
|
1186 |
+
return $options;
|
1187 |
+
}
|
1188 |
+
/**
|
1189 |
+
* converts a string into a php type version number
|
1190 |
+
* eg. 2.81.2 will become 2.8.1.2
|
1191 |
+
* used to prepare a number to be used with version_compare
|
1192 |
+
*
|
1193 |
+
* @param mixed $string - the version to be converted to php type version
|
1194 |
+
* @return string
|
1195 |
+
*/
|
1196 |
+
function php_version($string){
|
1197 |
+
if(empty($string)){
|
1198 |
+
return;
|
1199 |
+
}
|
1200 |
+
$version = str_replace('.','',$string);
|
1201 |
+
$std = array();
|
1202 |
+
for($i=0; $i < strlen($version); $i++){
|
1203 |
+
$std[] = $version[$i];
|
1204 |
+
}
|
1205 |
+
$php_version = implode('.',$std);
|
1206 |
+
return $php_version;
|
1207 |
+
}
|
1208 |
+
/** commentluv_action
|
1209 |
+
* This function adds a link to the settings page for the plugin on the plugins listing page
|
1210 |
+
* it is called by add filter plugin_action_links
|
1211 |
+
* @param $links - the links being filtered
|
1212 |
+
* @param $file - the name of the file
|
1213 |
+
* return array - the new array of links
|
1214 |
+
*/
|
1215 |
+
function plugin_action_link($links, $file) {
|
1216 |
+
$this_plugin = plugin_basename ( __FILE__ );
|
1217 |
+
if ($file == $this_plugin) {
|
1218 |
+
$links [] = "<a href='options-general.php?page={$this->slug}'>" . __ ( 'Settings', $this->plugin_domain ) . "</a>";
|
1219 |
+
}
|
1220 |
+
return $links;
|
1221 |
+
}
|
1222 |
+
/**
|
1223 |
+
* Detects if a commentluv api or plugin is requesting a feed
|
1224 |
+
* and sends back an xml feed of the post titles and links that were found for the query
|
1225 |
+
* called by add_filter('found_posts' so we always have the posts found for the requested category/author/tag/ etc
|
1226 |
+
* @param (int) $foundposts - the number of posts that were found
|
1227 |
+
* @param (obj) $object - the query object
|
1228 |
+
* @return $foundposts - need to return this if the request is not from a commentluv api or plugin
|
1229 |
+
*
|
1230 |
+
* deprecated in 2.90.9.9 due to new 3.4 wp query code messing up with static homepages.
|
1231 |
+
* have to use just 10 recent posts, does not detect author or category urls now. (no one uses them!)
|
1232 |
+
*/
|
1233 |
+
function send_feed($foundposts,$object){
|
1234 |
+
if(headers_sent() == true){
|
1235 |
+
return $foundposts;
|
1236 |
+
}
|
1237 |
+
$options = $this->get_options();
|
1238 |
+
// check if detection disabled
|
1239 |
+
if(isset($options['disable_detect']) && $options['disable_detect'] == 'on'){
|
1240 |
+
return $foundposts;
|
1241 |
+
}
|
1242 |
+
if($this->is_commentluv_request === true){
|
1243 |
+
// is commentluv useragent (set in init action)
|
1244 |
+
// get rid of any output (prevents some themes on some hosts from outputting code before commentluv can show xml feed)
|
1245 |
+
ob_clean();
|
1246 |
+
}
|
1247 |
+
$error = false;
|
1248 |
+
if($foundposts < 1 && ! $object->is_home){
|
1249 |
+
$error = true;
|
1250 |
+
}
|
1251 |
+
$enabled = $options['enable'];
|
1252 |
|
1253 |
+
// General checking
|
1254 |
+
if (preg_match("/Commentluv/i", $_SERVER['HTTP_USER_AGENT'])) {
|
1255 |
+
if($object->is_home){
|
1256 |
+
// we're on the home page so just get the last 10 posts (prevents a slider or other featured posts widget from making the object full of the featured posts)'
|
1257 |
+
wp_reset_query();
|
1258 |
+
$query = new WP_Query();
|
1259 |
+
remove_filter('found_posts',array(&$this,'send_feed'),-1,2);
|
1260 |
+
$object->posts = $query->query('showposts=10&post_type=post');
|
1261 |
+
}
|
1262 |
+
$feed = '<?xml version="1.0" encoding="'.get_bloginfo('charset').'" ?>
|
1263 |
+
<rss version="2.0">
|
1264 |
+
<channel>
|
1265 |
+
<title><![CDATA['. get_bloginfo('title') .']]></title>
|
1266 |
+
<link>'. home_url() .'</link>
|
1267 |
+
<description><![CDATA['. get_bloginfo('description') .']]></description>
|
1268 |
+
<language>'.get_bloginfo('language').'</language>
|
1269 |
+
<generator>commentluv?v='.$this->version.'</generator>
|
1270 |
+
<commentluv>'.$enabled.'</commentluv>
|
1271 |
+
<success>'.$error.'</success>';
|
1272 |
+
if($object->posts){
|
1273 |
+
foreach($object->posts as $post){
|
1274 |
+
$feed .= '<item><title><![CDATA['.get_the_title($post->ID).']]></title>
|
|
|
|
|
|
|
|
|
|
|
|
|
1275 |
<link>'.get_permalink($post->ID).'</link>
|
1276 |
+
<type>blog</type>
|
1277 |
</item>';
|
1278 |
}
|
1279 |
+
} else {
|
1280 |
+
$feed .= '<item><title>'.__('No Posts Were Found!',$pd).'</title>
|
1281 |
+
<link>'.get_permalink($post->ID).'</link>
|
1282 |
+
</item>';
|
1283 |
}
|
1284 |
+
$feed .= '</channel></rss>';
|
1285 |
+
header("Content-Type: application/xml; charset=".get_bloginfo('charset'));
|
1286 |
+
echo $feed;
|
1287 |
+
exit;
|
1288 |
}
|
1289 |
+
return $foundposts;
|
1290 |
+
}
|
1291 |
+
/** send back a feed when another commentluv is asking
|
1292 |
+
* called by add_action(template_redirect) in detect_useragent
|
1293 |
+
*
|
1294 |
+
*/
|
1295 |
+
function send_feed_file(){
|
1296 |
+
//debugbreak();
|
1297 |
+
$postquery = array('numberposts'=>10,'post_type'=>'post');
|
1298 |
+
if(is_category()){
|
1299 |
+
$cat = get_query_var('cat');
|
1300 |
+
$postquery['category']=$cat;
|
1301 |
+
}
|
1302 |
+
if(is_author()){
|
1303 |
+
$author = get_query_var('author');
|
1304 |
+
$postquery['author'] = $author;
|
1305 |
+
}
|
1306 |
+
if(is_tag()){
|
1307 |
+
$tag = get_query_var('tag');
|
1308 |
+
$postquery['tag'] = $tag;
|
1309 |
+
}
|
1310 |
+
$posts = get_posts($postquery);
|
1311 |
+
$enabled = $this->is_enabled();
|
1312 |
+
$error = 'false';
|
1313 |
+
if(sizeof($posts) < 1){
|
1314 |
+
$error = 'true';
|
1315 |
+
}
|
1316 |
+
$feed = '<?xml version="1.0" encoding="'.get_bloginfo('charset').'" ?>'.
|
1317 |
+
'<rss version="2.0">'.
|
1318 |
+
'<channel>'.
|
1319 |
+
'<title><![CDATA['. get_bloginfo('title') .']]></title>'.
|
1320 |
+
'<link>'. get_bloginfo('home') .'</link>'.
|
1321 |
+
'<description><![CDATA['. get_bloginfo('description') .']]></description>'.
|
1322 |
+
'<language>'.get_bloginfo('language').'</language>'.
|
1323 |
+
'<generator>commentluv?v='.$this->version.'</generator>'.
|
1324 |
+
'<commentluv>'.$enabled.'</commentluv>'.
|
1325 |
+
'<success>'.$error.'</success>';
|
1326 |
+
if(is_array($posts)){
|
1327 |
+
foreach($posts as $post){
|
1328 |
+
$title = get_the_title($post->ID);
|
1329 |
+
//$feed .= '<item><title>'.strip_tags($title).'</title>'.
|
1330 |
+
$feed .= '<item><title><![CDATA['.$title.']]></title>'.
|
|
|
|
|
|
|
|
|
1331 |
'<link>'.get_permalink($post->ID).'</link>'.
|
1332 |
+
'<type>blog</type>'.
|
1333 |
'</item>';
|
1334 |
+
}
|
1335 |
+
} else {
|
1336 |
+
$feed .= '<item><title>'.__('No Posts Were Found!',$pd).'</title>'.
|
1337 |
+
'<link>'.get_permalink($post->ID).'</link>'.
|
1338 |
+
'</item>';
|
|
|
|
|
1339 |
}
|
1340 |
+
$feed .= '</channel></rss>';
|
1341 |
+
ob_end_clean();
|
1342 |
+
header("Content-Type: application/atom+xml; charset=".get_bloginfo('charset'));
|
1343 |
+
echo $feed;
|
1344 |
+
exit;
|
|
|
|
|
|
|
|
|
|
|
1345 |
|
1346 |
+
}
|
1347 |
+
/**
|
1348 |
+
* called by __construct
|
1349 |
+
* used to setup hooks and filters for enabled plugin
|
1350 |
+
*/
|
1351 |
+
function setup_hooks(){
|
1352 |
+
add_action ( 'comment_form',array(&$this,'add_fields')); // add fields to form
|
1353 |
+
add_action ( 'wp_print_styles',array(&$this,'add_style')); // add style
|
1354 |
+
add_action ( 'template_redirect',array(&$this,'add_script')); // add commentluv script
|
1355 |
+
add_action ( 'admin_print_scripts-edit-comments.php', array (&$this, 'add_removeluv_script') ); // add the removeluv script to admin page
|
1356 |
+
add_action ( 'wp_footer',array(&$this,'add_footer')); // add localize to footer
|
1357 |
+
|
1358 |
+
add_action ( 'wp_insert_comment', array (&$this, 'comment_posted'),1,2); // add member id and other data to comment meta priority 1, 2 vars
|
1359 |
+
if(!is_admin()){
|
1360 |
+
add_filter ( 'comments_array', array (&$this, 'do_shortcode' ), 1 ); // add last blog post data to comment content
|
1361 |
+
} else {
|
1362 |
+
add_filter ( 'comment_text', array (&$this, 'do_shortcode' ), 1 ); // add last blog post data to comment content on admin screen
|
1363 |
+
}
|
1364 |
+
add_filter ( 'comment_row_actions', array (&$this,'add_removeluv_link')); // adds a link to remove the luv from a comment on the comments admin screen
|
1365 |
+
}
|
1366 |
+
/**
|
1367 |
+
* called by add_action('admin_notices in admin_init()
|
1368 |
+
* Used to show a notice if there is a new version of CommentLuv available
|
1369 |
+
*/
|
1370 |
+
function show_upgrade_notice(){
|
1371 |
+
$options = $this->get_options();
|
1372 |
+
$update_url = wp_nonce_url('update.php?action=upgrade-plugin&plugin=commentluv%2Fcommentluv.php', 'upgrade-plugin_commentluv/commentluv.php');
|
1373 |
+
echo '<div id="clupgrade" class="update-nag">';
|
1374 |
+
if($options['upgrade_message']){
|
1375 |
+
echo $options['upgrade_message'];
|
1376 |
+
$details_link = '<br /><a href="'.admin_url().'plugin-install.php?tab=plugin-information&plugin=commentluv&TB_iframe=true&width=640&height=350" class="thickbox" title="commentluv"> View new version details</a>';
|
1377 |
+
printf( __('%s or <a href="%s">update now</a>.', $this->plugin_domain), $details_link, $update_url ) ;
|
1378 |
+
} else {
|
1379 |
+
echo __('There is a new version of Commentluv available, please upgrade by visiting this site',$this->plugin_domain);
|
1380 |
+
echo '<br><a href="http://www.commentluv.com" target="_blank">www.commentluv.com</a>';
|
1381 |
}
|
1382 |
+
//echo '<span style="float:right"><a href="'.admin_url('options-general.php?page='.$this->slug.'&dismiss=true').'">'.__('Dismiss notice',$this->plugin_domain).'</a></span>';
|
1383 |
+
echo '</div>';
|
1384 |
+
}
|
1385 |
|
1386 |
+
/** options_page
|
1387 |
+
* This function shows the page for saving options
|
1388 |
+
* it is called by add_options_page
|
1389 |
+
* You can echo out or use further functions to display admin style widgets here
|
1390 |
+
*/
|
1391 |
+
function options_page(){
|
1392 |
+
$o = $this->get_options();
|
1393 |
+
$dbo = $this->db_option;
|
1394 |
+
$pd = $this->plugin_domain;
|
1395 |
+
$badges = array('default_image'=>'CL91_default.png','default'=>'CL91_default.png','white'=>'CL91_White.gif','black'=>'CL91_Black.gif','none'=> 'nothing.gif');
|
1396 |
+
//DebugBreak();
|
1397 |
+
// remove notice if requested
|
1398 |
+
if(isset($_GET['dismiss'])){
|
1399 |
+
unset($o['upgrade']);
|
1400 |
+
if(array_key_exists('upgrade_message',$o)){
|
1401 |
+
unset($o['upgrade_message']);
|
1402 |
+
}
|
1403 |
+
update_option($this->db_option,$o);
|
1404 |
+
echo '<script>jQuery("#clupgrade").hide()</script>';
|
1405 |
+
}
|
1406 |
?>
|
1407 |
<div class="wrap">
|
1408 |
<h2><?php _e('CommentLuv Settings v',$this->plugin_domain);?><?php echo $this->version;?></h2>
|
1410 |
<div id="mainblock" style="float: left; width:710px">
|
1411 |
<form method="post" action="options.php">
|
1412 |
<?php settings_fields( 'commentluv_options_group' ); // the name given in admin init
|
1413 |
+
// after here, put all the inputs and text fields needed
|
1414 |
?>
|
1415 |
<div class="dbx-content">
|
1416 |
<table class="widefat">
|
1426 |
<td>
|
1427 |
<p><?php _e('Do you like CommentLuv? How about an even better version with much more control over dofollow and some awesome social enticements that will make your posts go viral by offering your readers more choice of posts if they +1, Like or tweet your post? Get CommentLuv Premium Today!',$pd);?></p>
|
1428 |
<?php
|
1429 |
+
if(isset($o['subscribed'])){
|
1430 |
+
echo '<div class="submit">'.__('You have already subscribed, if you have not received the verification within 12 hours, please click the button to resend or try the form at',$pd).' <a target="_blank" href="http://www.commentluv.com/">www.commentluv.com</a><br><input style="margin:0 auto; display: block;" type="button" id="cl_notify" value="'.__('Resend Verification',$pd).'"/></div>';
|
1431 |
+
} else {
|
1432 |
+
echo '<div class="submit" style=" background-color: green; padding-left: 5px; padding-right: 5px; border-radius: 15px; -moz-border-radius: 15px; text-align: center;"><input style="margin: 0 auto; display:block" id="cl_notify" type="button" name="cl_notify" value="'.__('Click for a special offer!',$pd).'" /></div>';
|
1433 |
+
}
|
1434 |
?>
|
1435 |
<div id="notify_message"></div>
|
1436 |
</td>
|
1509 |
<input type="radio" class="radio" name="<?php echo $dbo;?>[badge_choice]" value="custom" <?php checked($o['badge_choice'],'custom');?>/>
|
1510 |
<input type="text" name="<?php echo $dbo;?>[custom_image_url]" value="<?php if(isset($o['custom_image_url'])) echo $o['custom_image_url'];?>"/>
|
1511 |
<?php
|
1512 |
+
if(isset($o['custom_image_url']) && $o['custom_image_url'] != ''){
|
1513 |
+
// show image
|
1514 |
+
echo '<p style="margin: 8px 0px 0px 8px;"><img id="custom_badge" style="border: 1px solid #000; padding: 3px;" src="'.$o['custom_image_url'].'"/></p>';
|
1515 |
} ?>
|
1516 |
</td>
|
1517 |
<td>
|
1530 |
<td><label for="<?php echo $dbo;?>[infotext]"><?php _e('Info panel text color',$pd);?></label><br><input type="text" size="6" name="<?php echo $dbo;?>[infotext];?>" value="<?php echo $o['infotext'];?>"/></td>
|
1531 |
<td></td>
|
1532 |
<?php
|
1533 |
+
$tdstyle = '"border: 1px solid #dfdfdf; vertical-align: middle; text-align: center; background-color: '.$o['infoback'].'"';
|
1534 |
+
$spanstyle = '"color: '.$o['infotext'].'"';
|
1535 |
?>
|
1536 |
<td style=<?php echo $tdstyle;?>><span style=<?php echo $spanstyle;?>><?php _e('Example text and background color',$pd);?></span></td>
|
1537 |
</tr>
|
1564 |
<br>(<?php _e('Message will not be shown if you do not have registrations enabled',$this->plugin_domain);?>)
|
1565 |
<br><textarea rows="5" style="width: 95%" name="<?php echo $dbo;?>[unreg_user_text]"><?php echo $o['unreg_user_text'];?></textarea>
|
1566 |
<?php
|
1567 |
+
if(get_option('users_can_register')){
|
1568 |
+
_e('Your register link code',$pd);
|
1569 |
+
echo '<br>';
|
1570 |
+
_e('(this will be automatically added if you have not added it yourself to the textarea above)',$pd);
|
1571 |
+
$register_link = apply_filters('register','<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>');
|
1572 |
+
echo ' : <input style="width:95%" type="text" value="'.htmlspecialchars($register_link).'" disabled/>';
|
1573 |
+
}
|
1574 |
?>
|
1575 |
</td>
|
1576 |
<td colspan="2" style="width:125px;">
|
1577 |
<?php // show warning if registration is not enabled
|
1578 |
+
if(!get_option('users_can_register')){
|
1579 |
+
echo '<div style="border: 2px dashed red;">';
|
1580 |
+
_e('You have NOT set your blog to allow registrations, you can do that in Settings/General',$pd);
|
1581 |
+
echo ' <a href="'.admin_url('options-general.php').'">'.__('here',$pd).'</a>';
|
1582 |
+
echo '</div>';
|
1583 |
+
}
|
1584 |
?>
|
1585 |
</td>
|
1586 |
</tr>
|
1730 |
<tr>
|
1731 |
<td colspan="4"><textarea style="width: 99%" rows="5">
|
1732 |
<?php
|
1733 |
+
$options = $this->get_options();
|
1734 |
+
$options['version'] = $this->version;
|
1735 |
+
$options['home_url'] = get_home_url();
|
1736 |
+
$options['wp_version'] = get_bloginfo('version');
|
1737 |
+
$options['charset'] = get_bloginfo('charset');
|
1738 |
+
$options['curl'] = function_exists('curl_init')? 'yes': 'no';
|
1739 |
|
1740 |
+
print_r($options);
|
1741 |
|
1742 |
?>
|
1743 |
</textarea>
|
1745 |
<td>
|
1746 |
<?php _e('You can copy this information and send it to me if I request it',$pd);?>
|
1747 |
</td>
|
1748 |
+
</tr>
|
1749 |
</tbody>
|
1750 |
</table>
|
1751 |
+
<p></p>
|
1752 |
+
<table class="widefat">
|
1753 |
+
<tr>
|
1754 |
+
<td>
|
1755 |
+
<?php
|
1756 |
+
//debugbreak();
|
1757 |
+
include_once(ABSPATH.WPINC.'/feed.php');
|
1758 |
+
$rss = fetch_feed('http://comluv.com/category/ads/feed/');
|
1759 |
+
if(!is_wp_error($rss)) {
|
1760 |
+
$maxitems = $rss->get_item_quantity(2);
|
1761 |
+
$rssitems = $rss->get_items(0,$maxitems);
|
1762 |
+
}
|
1763 |
+
foreach($rssitems as $item){
|
1764 |
+
echo '<div><a href="'.esc_url( $item->get_permalink() ).'">'.esc_html($item->get_title()).'</a>';
|
1765 |
+
echo '<p>'.$item->get_content().'</p></div>';
|
1766 |
+
}
|
1767 |
+
?>
|
1768 |
+
</td>
|
1769 |
+
</tr>
|
1770 |
+
</table>
|
1771 |
|
1772 |
</div>
|
1773 |
<div class="submit"><input class="button-primary" id="clsubmit" type="submit" name="Submit" value="<?php _e('Save Settings',$this->plugin_domain);?>" /></div>
|
1775 |
<h3><?php _e('Reset Settings',$this->plugin_domain);?></h3>
|
1776 |
<form method="post" action="options.php">
|
1777 |
<?php settings_fields( 'commentluv_options_group' ); // the name given in admin init
|
1778 |
+
$javamsg = __('Are you sure you want to reset your settings? Press OK to continue',$this->plugin_domain);
|
1779 |
?>
|
1780 |
<input type="hidden" name="<?php echo $this->db_option;?>[reset]" value="yes"/>
|
1781 |
<input style="background-color: red;" type="submit" onclick="<?php echo 'if(confirm(\''.$javamsg.'\') != true) { return false; } else { return true; } ';?>" value="<?php _e('Reset',$this->plugin_domain);?>" name="submit"/>
|
1799 |
<tr class="alt"><td colspan="2"><?php _e('News',$this->plugin_domain);?>:</td></tr>
|
1800 |
<tr><td colspan="2">
|
1801 |
<?php
|
1802 |
+
include_once(ABSPATH . WPINC . '/feed.php');
|
1803 |
+
if(function_exists('fetch_feed')){
|
1804 |
+
//debugBreak();
|
1805 |
+
$uri = 'http://comluv.com/category/newsletter/feed/';
|
1806 |
+
$feed = fetch_feed($uri);
|
1807 |
+
if(!is_wp_error($feed)){
|
1808 |
+
$rss_items = $feed->get_items(0,3);
|
1809 |
+
if($rss_items){
|
1810 |
+
foreach($rss_items as $item){
|
1811 |
?>
|
1812 |
<ul>
|
1813 |
<li>
|
1817 |
</li>
|
1818 |
</ul>
|
1819 |
<?php
|
|
|
1820 |
}
|
1821 |
}
|
1822 |
}
|
1823 |
+
}
|
1824 |
|
1825 |
?>
|
1826 |
</td></tr>
|
1870 |
</div>
|
1871 |
<?php
|
1872 |
|
1873 |
+
}
|
1874 |
|
1875 |
|
1876 |
+
} // end class
|
1877 |
+
} // end if class not exists
|
1878 |
+
// Let's give commentluv plenty of room to work with
|
1879 |
+
$mem = abs(intval(@ini_get('memory_limit')));
|
1880 |
+
if( $mem and $mem < 128 ){
|
1881 |
+
@ini_set('memory_limit', '128M');
|
1882 |
+
}
|
1883 |
+
$clbadgeshown = false;
|
1884 |
+
// start commentluv class engines
|
1885 |
+
if (class_exists ( 'commentluv' )) :
|
1886 |
+
$commentluv = new commentluv ( );
|
1887 |
+
// confirm warp capability
|
1888 |
+
if (isset ( $commentluv )) {
|
1889 |
+
// engage
|
1890 |
+
register_activation_hook ( __FILE__, array (&$commentluv, 'install' ) );
|
1891 |
}
|
1892 |
+
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1893 |
|
1894 |
+
function cl_display_badge(){
|
1895 |
+
global $commentluv;
|
1896 |
+
if(isset($commentluv)){
|
1897 |
+
$commentluv->display_badge();
|
1898 |
}
|
1899 |
+
|
1900 |
+
}
|
1901 |
?>
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: commentluv, @hishaman (css additions)
|
|
3 |
Donate link:http://comluv.com/about/donate
|
4 |
Tags: commentluv, comments, last blog post, linkluv, comment luv , commentlove, comment love
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 3.6
|
7 |
-
Stable tag: 2.92.
|
8 |
|
9 |
Reward your readers by automatically placing a link to their last blog post at the end of their comment. Encourage a community and discover new posts.
|
10 |
|
@@ -87,6 +87,11 @@ Please see the videos in the settings page for explanations of how they work.
|
|
87 |
|
88 |
== ChangeLog ==
|
89 |
|
|
|
|
|
|
|
|
|
|
|
90 |
= 2.92.8 =
|
91 |
|
92 |
* updated : translation for Bengali
|
@@ -396,9 +401,9 @@ Please see the videos in the settings page for explanations of how they work.
|
|
396 |
|
397 |
== Upgrade Notice ==
|
398 |
|
399 |
-
= 2.92.
|
400 |
|
401 |
-
|
402 |
|
403 |
== Configuration ==
|
404 |
|
3 |
Donate link:http://comluv.com/about/donate
|
4 |
Tags: commentluv, comments, last blog post, linkluv, comment luv , commentlove, comment love
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 3.6.1
|
7 |
+
Stable tag: 2.92.9
|
8 |
|
9 |
Reward your readers by automatically placing a link to their last blog post at the end of their comment. Encourage a community and discover new posts.
|
10 |
|
87 |
|
88 |
== ChangeLog ==
|
89 |
|
90 |
+
= 2.92.9 =
|
91 |
+
|
92 |
+
* updated : settings page panel for ads
|
93 |
+
* updated : compatibility setting
|
94 |
+
|
95 |
= 2.92.8 =
|
96 |
|
97 |
* updated : translation for Bengali
|
401 |
|
402 |
== Upgrade Notice ==
|
403 |
|
404 |
+
= 2.92.9 =
|
405 |
|
406 |
+
updated compatibility
|
407 |
|
408 |
== Configuration ==
|
409 |
|