CommentLuv - Version 2.80

Version Description

  • Wordpress 3.0 Compatible
  • Use comments meta table instead of hard coding into the comment content
  • Drastically improved commmunication with API for comment status changes
  • Near 100% accuracy for API to identify members links for info panel
  • New heart icon for registered members. Improves hover rates.
  • Removed depreciated function to clean old style additional data
  • Added link to remove someones luvlink data in the comments admin page
  • Dutch Translation by Rene wppg.me
  • Added comments_array filter to make Thesis behave
  • Added check to see if link already added (WP 3.0 compatibility)
  • thanks to @hishaman for helping the thesis testing
  • Added code to settings manager to prevent viewing outside wordpress (and fixed the typo later, thanks speedforce.org)
Download this release

Release Info

Developer teamplaylotto
Plugin Icon 128x128 CommentLuv
Version 2.80
Comparing to
See all releases

Code changes from version 2.7.6.9 to 2.80

commentluv-manager.php CHANGED
@@ -1,8 +1,18 @@
1
- <?php
2
- // commentluv 2.7 options page?>
 
 
 
 
 
 
 
 
 
3
  <div class="wrap" style="max-width:950px !important;">
4
- <h2>CommentLuv 2.7</h2>
5
  <div id="poststuff" style="margin-top:10px;">
 
6
  <div id="mainblock" style="width:710px">
7
  <div class="dbx-content">
8
  <form action="<?php echo $action_url ?>" method="POST">
1
+ <?php
2
+ global $wpdb;
3
+ if(!$wpdb){
4
+ // not run from wordpress
5
+ ?>
6
+ <h1>CommentLuv 2.80</h1>
7
+ <p>This is the settings page for CommentLuv 2.80 and should not be viewed outside of the Wordpress dashboard</p>
8
+ <p>You can download the latest version version of CommentLuv at Wordpress.org</p>
9
+ <?php exit;
10
+ }
11
+ ?>
12
  <div class="wrap" style="max-width:950px !important;">
13
+ <h2>CommentLuv 2.80</h2>
14
  <div id="poststuff" style="margin-top:10px;">
15
+ <div style="float:right"><?php _e('Donate to comluv',$this->plugin_domain);?><br/><script language="JavaScript" src="http://pos.pay.mobilefirst.com/impress/5000026800000165/?site_url=<?php echo urlencode(site_url());?>"></script></div>
16
  <div id="mainblock" style="width:710px">
17
  <div class="dbx-content">
18
  <form action="<?php echo $action_url ?>" method="POST">
commentluv.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php /* CommentLuv 2.7
2
  Plugin Name: CommentLuv
3
  Plugin URI: http://comluv.com/download/commentluv-wordpress/
4
  Description: Plugin to show a link to the last post from the commenters blog by parsing the feed at their given URL when they leave a comment. Rewards your readers and encourage more comments.
5
- Version: 2.7.69
6
  Author: Andy Bailey
7
  Author URI: http://fiddyp.co.uk/
8
  */
@@ -14,8 +14,9 @@ if (! class_exists ( 'commentluv' )) {
14
  var $plugin_domain = 'commentluv';
15
  var $plugin_url;
16
  var $db_option = 'commentluv_options';
17
- var $cl_version = 276;
18
  var $api_url;
 
19
 
20
  //initialize the plugin
21
  function commentluv() {
@@ -26,26 +27,36 @@ if (! class_exists ( 'commentluv' )) {
26
  if (in_array ( $pagenow, $local_pages ) || in_array ( $_GET ['page'], $local_pages )) {
27
  $this->handle_load_domain ();
28
  }
29
- $exit_msg = __ ( 'CommentLuv requires Wordpress 2.6.5 or newer.', $this->plugin_domain ) . '<a href="http://codex.wordpress.org/Upgrading_Wordpress">' . __ ( 'Please Update!', $this->plugin_domain ) . '</a>';
30
 
31
  // can you dig it?
32
- if (version_compare ( $wp_version, "2.6.5", "<" )) {
33
  exit ( $exit_msg ); // no diggedy
34
  }
35
 
36
  // action hooks
37
  $this->plugin_url = trailingslashit ( WP_PLUGIN_URL . '/' . dirname ( plugin_basename ( __FILE__ ) ) );
38
- $this->api_url = 'http://api.comluv.com/cl_api/commentluvapi.php';
39
- //$this->api_url = 'http://firedwok.com/api/cl_api/commentluvapi.php';
40
- add_action ( 'admin_menu', array (&$this, 'admin_menu' ) );
 
 
 
 
 
 
 
 
41
  add_action ( 'template_redirect', array (&$this, 'commentluv_scripts' ) ); // template_redirect always called when page is displayed to user
42
  add_action ( 'wp_head', array (&$this, 'commentluv_style' ) ); // add style sheet to header
43
  add_action ( 'wp_set_comment_status', array (&$this, 'update_cl_status' ), 1, 3 ); // call when status of comment gets changed
44
  add_action ( 'comment_post', array (&$this, 'update_cl_status' ), 2, 3 ); // call when comment gets posted
45
  add_action ( 'comment_form', array (&$this, 'add_fields' ) ); // add hidden fields during comment form display time
 
46
  add_filter ( 'plugin_action_links', array (&$this, 'commentluv_action' ), - 10, 2 ); // add a settings page link to the plugin description. use 2 for allowed vars
47
- add_filter ( 'comment_text', array (&$this, 'do_shortcode' ), 10 ); // replace inserted data with hidden span on display time of comment
48
- add_filter ( 'pre_comment_content', array (&$this, 'cl_post' ), 10 ); // extract extra fields data and insert data to end of comment
 
49
  }
50
 
51
  // hook the options page
@@ -54,6 +65,9 @@ if (! class_exists ( 'commentluv' )) {
54
  $menutitle .= 'CommentLuv';
55
  add_options_page ( 'CommentLuv Settings', $menutitle, 8, basename ( __FILE__ ), array (&$this, 'handle_options' ) );
56
  }
 
 
 
57
  // add the settings link
58
  function commentluv_action($links, $file) {
59
  $this_plugin = plugin_basename ( __FILE__ );
@@ -62,18 +76,47 @@ if (! class_exists ( 'commentluv' )) {
62
  }
63
  return $links;
64
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  // hook the template_redirect for inserting style and javascript (using wp_head would make it too late to add dependencies)
66
  function commentluv_scripts() {
67
  // only load scripts if on a single page
68
  if (is_single ()) {
69
  wp_enqueue_script ( 'jquery' );
70
- global $wp_version;
71
- // see if hoverintent library is already included (2.7 >)
72
- if (version_compare ( $wp_version, "2.8", "<" )) {
73
- wp_enqueue_script ( 'hoverIntent', '/' . PLUGINDIR . '/' . dirname ( plugin_basename ( __FILE__ ) ) . '/js/hoverIntent.js', array ('jquery' ) );
74
- } else {
75
- wp_enqueue_script ( 'hoverIntent', '/' . WPINC . '/js/hoverIntent.js', array ('jquery' ) );
76
- }
77
  wp_enqueue_script ( 'commentluv', $this->plugin_url . 'js/commentluv.js', array ('jquery' ) );
78
  // get options
79
  $options = $this->get_options ();
@@ -108,7 +151,7 @@ if (! class_exists ( 'commentluv' )) {
108
  // get plugin options
109
  function get_options() {
110
  // default values
111
- $options = array ('comment_text' => '[name]&#180;s last [type] ..[lastpost]', 'select_text' => 'choose a different post to show', 'default_on' => 'on', 'heart_tip' => 'on', 'use_template' => '', 'badge' => 'CL91x17-white2.gif', 'show_text' => 'CommentLuv Enabled', 'author_name' => 'author', 'url_name' => 'url', 'comment_name' => 'comment', 'email_name' => 'email', 'prepend' => '', 'infoback' => 'pink' );
112
  // get saved options unless reset button was pressed
113
  $saved = '';
114
  if (! isset ( $_POST ['reset'] )) {
@@ -254,6 +297,7 @@ if (! class_exists ( 'commentluv' )) {
254
  echo '<input type="hidden" name="request_id" />';
255
  echo '<input type="hidden" name="cl_post_title" id="cl_post_title"/>';
256
  echo '<input type="hidden" name="cl_post_url" id="cl_post_url"/>';
 
257
  $fieldsadded = TRUE;
258
  }
259
  // check if using php call comments.php or not
@@ -265,111 +309,109 @@ if (! class_exists ( 'commentluv' )) {
265
  }
266
 
267
  // hook the pre_comment_content to add the link
268
- function cl_post($commentdata) {
269
- if (isset ( $_POST ['cl_post_title'] ) && $_POST ['request_id'] != '' && is_numeric ( $_POST ['choice_id'] ) && isset ( $_POST ['cl_type'] )) {
270
- if(!defined('LUVEDIT')){
271
- define("LUVEDIT",1);
272
- } else {
273
- // already been here so shoo!
274
- return $commentdata;
275
- }
276
- // get values posted
277
- $luvlink = '<a href="'.$_POST ['cl_post_url'].'">'.$_POST['cl_post_title'].'</a>';
278
- if (strstr ( $luvlink, "commentluv.com/error-check" ) || $_POST ['request_id'] == 0) {
279
- return $commentdata;
280
- }
281
- $request_id = $_POST ['request_id'];
282
- $choice_id = $_POST ['choice_id'];
283
- $cl_type = $_POST ['cl_type'];
284
- // convert data to put into comment content
285
- $options = get_option ( $this->db_option );
286
- $prepend_text = $options ['comment_text'];
287
- $search = array ('[name]', '[type]', '[lastpost]' );
288
- $replace = array ($_POST ["{$options['author_name']}"], $cl_type, $luvlink );
289
- $inserted = str_replace ( $search, $replace, $prepend_text );
290
- // insert identifying data and insert text/link to end of comment
291
- $commentdata .= "\n.-= $inserted =-.";
292
- // tell comluv that the comment was submitted
293
- $luvlink = stripslashes ( $luvlink );
294
- $thelinkstart = strpos ( $luvlink, '="' );
295
- $cutit = substr ( $luvlink, $thelinkstart + 2 );
296
- $hrefend = strpos ( $cutit, '"' );
297
- $thelink = substr ( $cutit, 0, $hrefend );
298
- // got the url, construct url to tell comluv
299
- $url = $this->api_url . "?type=approve&request_id=$request_id&post_id=$choice_id&url=$thelink&refer=".get_permalink();
300
- $content = $this->call_comluv ( $url );
301
  }
302
- return $commentdata;
303
  }
304
  // hook the set comment status action
305
  function update_cl_status($cid, $status) {
306
- // get comment stuff from id
307
-
308
- if ($status != 'spam') {
309
- if ($status != 'delete') {
310
- $status = 'approve';
 
 
 
 
311
  }
312
- $comment = get_comment ( $cid );
313
- if (strpos ( $comment->comment_content, ".-=" )) {
314
- // comment can be approved or deleted in the comluv db
315
- $url = $this->api_url . "?type={$status}&url=";
316
- // get the link
317
- $commentcontent = $comment->comment_content;
318
- $start = $this->my_strrpos( $commentcontent, '.-=' );
319
- $thelink = substr ( $commentcontent, $start + 4, strlen ( $commentcontent ) - $start - 5 );
320
- $hrefstart = strpos ( $thelink, '="' );
321
- $cutit = substr ( $thelink, $hrefstart + 2 );
322
- $hrefend = strpos ( $cutit, '"' );
323
- $thelink = substr ( $cutit, 0, $hrefend );
324
- // get comment date
325
- $date = $comment->comment_date_gmt;
326
- // construct url with added params for approving comment to comluv
327
- $url .= $thelink . "&comment_date=$date&version=" . $this->cl_version;
328
- // call the url ..
329
- $content = $this->call_comluv ( $url );
330
- } // end if comment content contains a .-=
331
  }
332
  }
 
333
  // use my own shortcode that was inserted at submission time and hide the params
334
- function do_shortcode($commentcontent) {
 
335
  $options = get_option ( $this->db_option );
336
- if (strpos ( $commentcontent, ".-=" ) && strpos ( $commentcontent, "=-." )) {
337
- $last_pos = $this->my_strrpos ( $commentcontent, ".-=" ); // position number for last occurence of .-=
338
- $beforecltext = substr ( $commentcontent, 0, $last_pos ); // get text before last position of .-=
339
- $cltext = substr ( $commentcontent, $last_pos ); // get the bit between .-= and =-.
340
- $cltext = str_replace ( array (".-=", "=-." ), array ('<span class="cluv">', '' ), $cltext ); // replace .-= with span and chop off last =-.
341
- $commentcontent = $beforecltext . $cltext;
342
- // do heart info
343
- if ($options ['heart_tip'] == 'on') {
344
- $commentcontent .= '<span class="heart_tip_box"><img class="heart_tip" alt="My ComLuv Profile" border="0" width="16" height="14" src="' . $this->plugin_url . 'images/littleheart.gif"/></span>';
345
  }
346
- $commentcontent .= '</span>';
347
- }
348
-
349
- // remove old codes
350
- if (strpos ( $commentcontent, "[rq=" ) && strpos ( $commentcontent, "[/rq]" )) {
351
- // get bit that was added
352
- $start = strpos ( $commentcontent, '[rq=' );
353
- $end = strpos ( $commentcontent, '[/rq]' ) + 5;
354
- $params = substr ( $commentcontent, $start, $end - $start );
355
- global $comment;
356
- $author_name = $comment->comment_author;
357
- $author_url = $comment->comment_author_url;
358
- // get array of params
359
- $params_arr = explode ( ",", substr ( $params, 4, - 6 ) );
360
- // get and prepare the text specified by the user
361
- $prepend_text = $options ['comment_text'];
362
- $search = array ('[name]', '[type]', '[lastpost]' );
363
- $replace = array ($author_name, $params_arr [2], '' );
364
- $inserted = '<span class="cluv">';
365
- $inserted .= str_replace ( $search, $replace, $prepend_text );
366
- $commentcontent = str_replace ( $params, $inserted, $commentcontent );
367
- if ($options ['heart_tip'] == 'on') {
368
- $commentcontent .= '<span class="heart_tip_box"><img class="heart_tip" alt="My ComLuv Profile" border="0" width="16" height="14" src="' . $this->plugin_url . 'images/littleheart.gif"/></span>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
369
  }
370
- $commentcontent .= '</span>';
 
 
 
 
 
 
 
 
 
 
 
 
371
  }
372
- return $commentcontent;
373
  }
374
 
375
  // set up default values
1
+ <?php /* CommentLuv 2.8
2
  Plugin Name: CommentLuv
3
  Plugin URI: http://comluv.com/download/commentluv-wordpress/
4
  Description: Plugin to show a link to the last post from the commenters blog by parsing the feed at their given URL when they leave a comment. Rewards your readers and encourage more comments.
5
+ Version: 2.80
6
  Author: Andy Bailey
7
  Author URI: http://fiddyp.co.uk/
8
  */
14
  var $plugin_domain = 'commentluv';
15
  var $plugin_url;
16
  var $db_option = 'commentluv_options';
17
+ var $cl_version = 280;
18
  var $api_url;
19
+ var $test = false;
20
 
21
  //initialize the plugin
22
  function commentluv() {
27
  if (in_array ( $pagenow, $local_pages ) || in_array ( $_GET ['page'], $local_pages )) {
28
  $this->handle_load_domain ();
29
  }
30
+ $exit_msg = __ ( 'CommentLuv requires Wordpress 2.9.2 or newer.', $this->plugin_domain ) . '<a href="http://codex.wordpress.org/Upgrading_Wordpress">' . __ ( 'Please Update!', $this->plugin_domain ) . '</a>';
31
 
32
  // can you dig it?
33
+ if (version_compare ( $wp_version, "2.9.2", "<" )) {
34
  exit ( $exit_msg ); // no diggedy
35
  }
36
 
37
  // action hooks
38
  $this->plugin_url = trailingslashit ( WP_PLUGIN_URL . '/' . dirname ( plugin_basename ( __FILE__ ) ) );
39
+ if($this->test){
40
+ $this->api_url = 'http://firedwok.com/cl_api/commentluvapi.php';
41
+ } else {
42
+ $this->api_url = 'http://api.comluv.com/cl_api/commentluvapi.php';
43
+ }
44
+
45
+ //
46
+ add_action ( 'admin_menu', array (&$this, 'admin_menu' ) ); // add image to admin link and setup options page
47
+ add_action ( 'admin_print_scripts-post.php', array (&$this, 'add_removeluv_script') ); // add the removeluv script to admin page
48
+ add_action ( 'admin_print_scripts-edit-comments.php', array (&$this, 'add_removeluv_script') ); // add the removeluv script to admin page
49
+ add_action ( 'wp_ajax_removeluv', array (&$this, 'cl_remove_luv') ); // handle the call to the admin-ajax for removing luv
50
  add_action ( 'template_redirect', array (&$this, 'commentluv_scripts' ) ); // template_redirect always called when page is displayed to user
51
  add_action ( 'wp_head', array (&$this, 'commentluv_style' ) ); // add style sheet to header
52
  add_action ( 'wp_set_comment_status', array (&$this, 'update_cl_status' ), 1, 3 ); // call when status of comment gets changed
53
  add_action ( 'comment_post', array (&$this, 'update_cl_status' ), 2, 3 ); // call when comment gets posted
54
  add_action ( 'comment_form', array (&$this, 'add_fields' ) ); // add hidden fields during comment form display time
55
+ add_action ( 'wp_insert_comment', array (&$this, 'cl_post'),1,2); // add member id and other data to comment meta priority 1, 2 vars
56
  add_filter ( 'plugin_action_links', array (&$this, 'commentluv_action' ), - 10, 2 ); // add a settings page link to the plugin description. use 2 for allowed vars
57
+ add_filter ( 'comments_array', array (&$this, 'do_shortcode' ), 1 ); // replace inserted data with hidden span on display time of comment
58
+ add_filter ( 'comment_text', array (&$this, 'do_shortcode' ), 1 ); // add last blog post data to comment content on admin screen
59
+ 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
60
  }
61
 
62
  // hook the options page
65
  $menutitle .= 'CommentLuv';
66
  add_options_page ( 'CommentLuv Settings', $menutitle, 8, basename ( __FILE__ ), array (&$this, 'handle_options' ) );
67
  }
68
+ function add_removeluv_script(){
69
+ wp_enqueue_script ( 'commentluv', $this->plugin_url . 'js/adminremoveluv.js', array ('jquery' ) );
70
+ }
71
  // add the settings link
72
  function commentluv_action($links, $file) {
73
  $this_plugin = plugin_basename ( __FILE__ );
76
  }
77
  return $links;
78
  }
79
+ // add removeluv link
80
+ function add_removeluv_link($actions){
81
+ global $post;
82
+ $user_can = current_user_can('edit_post', $post->ID);
83
+ if(get_comment_meta(get_comment_ID(),'cl_data')){
84
+ if($user_can){
85
+ $nonce= wp_create_nonce ('removeluv'.get_comment_ID());
86
+ $actions['Remove-luv'] = '<a class="removeluv :'.get_comment_ID().':'.$nonce.'" href="wp-admin/edit-comments.php">Remove Luv</a>';
87
+ }
88
+ }
89
+ return $actions;
90
+ }
91
+ // remove luvlink from comment when called by admin-ajax
92
+ function cl_remove_luv(){
93
+ // check user is allowed to do this
94
+ $nonce=$_REQUEST['_wpnonce'];
95
+ $cid = $_REQUEST['c'];
96
+ if (! wp_verify_nonce($nonce, 'removeluv'.$cid) ) die("Epic fail");
97
+ // delete meta if comment id sent with request
98
+ if($cid){
99
+ // get meta and set vars if exists
100
+ $cmeta =get_comment_meta($cid,'cl_data','true');
101
+ if($cmeta) extract($cmeta);
102
+ // delete it and call comluv to tell it what happened
103
+ if(delete_comment_meta($cid,'cl_data')){
104
+ $url = $this->api_url.'?type=update&updatetype=delete&request_id='.$cl_requestid.'&choice_id='.$cl_choiceid.'&version='.$temp->cl_version;
105
+ $status = $this->call_comluv($url);
106
+ // return the comment id and status code for js processing to hide luv
107
+ echo "$cid*$status*";
108
+ return;
109
+ }
110
+ } else {
111
+ echo '0';
112
+ }
113
+ }
114
  // hook the template_redirect for inserting style and javascript (using wp_head would make it too late to add dependencies)
115
  function commentluv_scripts() {
116
  // only load scripts if on a single page
117
  if (is_single ()) {
118
  wp_enqueue_script ( 'jquery' );
119
+ wp_enqueue_script ( 'hoverIntent', '/' . WPINC . '/js/hoverIntent.js', array ('jquery' ) );
 
 
 
 
 
 
120
  wp_enqueue_script ( 'commentluv', $this->plugin_url . 'js/commentluv.js', array ('jquery' ) );
121
  // get options
122
  $options = $this->get_options ();
151
  // get plugin options
152
  function get_options() {
153
  // default values
154
+ $options = array ('comment_text' => '[name] recently posted..[lastpost]', 'select_text' => 'choose a different post to show', 'default_on' => 'on', 'heart_tip' => 'on', 'use_template' => '', 'badge' => 'CL91x17-white2.gif', 'show_text' => 'CommentLuv Enabled', 'author_name' => 'author', 'url_name' => 'url', 'comment_name' => 'comment', 'email_name' => 'email', 'prepend' => '', 'infoback' => 'pink' );
155
  // get saved options unless reset button was pressed
156
  $saved = '';
157
  if (! isset ( $_POST ['reset'] )) {
297
  echo '<input type="hidden" name="request_id" />';
298
  echo '<input type="hidden" name="cl_post_title" id="cl_post_title"/>';
299
  echo '<input type="hidden" name="cl_post_url" id="cl_post_url"/>';
300
+ echo '<input type="hidden" name="cl_memberid" id="cl_memberid"/>';
301
  $fieldsadded = TRUE;
302
  }
303
  // check if using php call comments.php or not
309
  }
310
 
311
  // hook the pre_comment_content to add the link
312
+ function cl_post($id,$commentdata) {
313
+ $cl_requestid = intval($_POST['request_id']);
314
+ if($cl_requestid > 1){
315
+ // only do stuff if the comment had a successful last blog post
316
+ // and if the meta hasn't been added yet.
317
+ // (request id will be -1 if error, or no posts returned.)
318
+ $cl_memberid = intval($_POST['cl_memberid']);
319
+ $cl_choiceid = intval($_POST['choice_id']);
320
+ $cl_post_title = apply_filters('kses',$_POST['cl_post_title']);
321
+ $cl_post_url = apply_filters('kses',$_POST['cl_post_url']);
322
+ $cl_type = apply_filters('kses',$_POST['cl_type']);
323
+ $data = array('cl_memberid'=>$cl_memberid,'cl_requestid'=>$cl_requestid,'cl_choiceid'=>$cl_choiceid,'cl_post_title'=>$cl_post_title,'cl_post_url'=>$cl_post_url,'cl_type'=>$cl_type);
324
+ add_comment_meta($id,'cl_data',$data,'true');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  }
 
326
  }
327
  // hook the set comment status action
328
  function update_cl_status($cid, $status) {
329
+ // get comment stuff from meta
330
+ $data = get_comment_meta($cid,'cl_data','true');
331
+ if($data && is_array($data)){
332
+ extract($data);
333
+ $url = $this->api_url.'?type=update&updatetype='.$status.'&request_id='.$cl_requestid.'&choice_id='.$cl_choiceid.'&version='.$this->cl_version;
334
+ $content = $this->call_comluv ( $url );
335
+ if($this->test){
336
+ update_option('cl_last_comment_status',"$cid was $status");
337
+ update_option('cl_last_response',$content);
338
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  }
340
  }
341
+
342
  // use my own shortcode that was inserted at submission time and hide the params
343
+ function do_shortcode($commentarray) {
344
+ $isadminpage = 0;
345
  $options = get_option ( $this->db_option );
346
+ if(!is_array($commentarray)){
347
+ // if it's an array then it was called by comments_array filter,
348
+ // otherwise it was called by comment_content (admin screen)
349
+ // has it been done before?
350
+ if(strpos($commentarray,'class="cluv"')){
351
+ return $commentarray;
 
 
 
352
  }
353
+ // make a fake array of 1 object so below treats the comment_content filter nicely for admin screen
354
+ $temparray = array('comment_ID'=>get_comment_ID(),'comment_content'=>$commentarray,'comment_author'=>get_comment_author());
355
+ $tempobject = (object) $temparray;
356
+ $commentarray = array($tempobject);
357
+ $isadminpage = 1;
358
+ }
359
+ // step through each comment in the array and add the shizzle to the nizzle (stoopid thesis make me do this instead of filtering comment_text)
360
+ $new_commentarray = array();
361
+ foreach($commentarray as $comment){
362
+ $data = get_comment_meta($comment->comment_ID,'cl_data','true');
363
+ $commentcontent = $comment->comment_content;
364
+ if (strpos ( $commentcontent, ".-=" ) && strpos ( $commentcontent, "=-." )) {
365
+ // handle old 2.7691 comments with hardcoded link
366
+ $last_pos = $this->my_strrpos ( $commentcontent, ".-=" ); // position number for last occurence of .-=
367
+ $beforecltext = substr ( $commentcontent, 0, $last_pos ); // get text before last position of .-=
368
+ $cltext = substr ( $commentcontent, $last_pos ); // get the bit between .-= and =-.
369
+ $cltext = str_replace ( array (".-=", "=-." ), array ('<span class="cluv">', '' ), $cltext ); // replace .-= with span and chop off last =-.
370
+ $commentcontent = $beforecltext . $cltext;
371
+ // do heart info
372
+ if ($options ['heart_tip'] == 'on') {
373
+ $commentcontent .= '<span class="heart_tip_box"><img class="heart_tip" alt="My ComLuv Profile" border="0" width="16" height="14" src="' . $this->plugin_url . 'images/littleheart.gif"/></span>';
374
+ }
375
+ $commentcontent .= '</span>';
376
+ }
377
+ // handle new 2.80+ comments with hidden post data
378
+ if($data){
379
+ // has meta data associated
380
+ extract($data,EXTR_OVERWRITE);
381
+ //array('cl_memberid'=>$cl_memberid,'cl_requestid'=>$cl_requestid,'cl_choiceid'=>$cl_choiceid,'cl_post_title'=>$cl_post_title,'cl_post_url'=>$cl_post_url,'cl_type'=>$cl_type);
382
+ // add link to comment
383
+ $luvlink = '<a href="'.$cl_post_url.'">'.$cl_post_title.'</a>';
384
+ $prepend_text = $options ['comment_text'];
385
+ $search = array ('[name]', '[type]', '[lastpost]' );
386
+ $replace = array ($comment->comment_author, $cl_type, $luvlink );
387
+ $inserted = str_replace ( $search, $replace, $prepend_text );
388
+ // insert identifying data and insert text/link to end of comment
389
+ $commentcontent .= "\n<span class=\"cluv\">$inserted";
390
+ // prepare heart icon
391
+ $hearticon = '';
392
+ if($cl_memberid > 2 ){
393
+ // use PLUS heart for members
394
+ $hearticon = 'plus';
395
+ }
396
+ if ($options ['heart_tip'] == 'on') {
397
+ $commentcontent .= '<span class="heart_tip_box"><img class="heart_tip '.$cl_memberid.'" alt="My ComLuv Profile" border="0" width="16" height="14" src="' . $this->plugin_url . 'images/littleheart'.$hearticon.'.gif"/></span>';
398
+ }
399
+ $commentcontent.= '</span>';
400
  }
401
+ // store new content in this comments comment_content cell
402
+ $comment->comment_content = $commentcontent;
403
+ // fill new array with this comment
404
+ $new_commentarray[] = $comment;
405
+ }
406
+
407
+ // admin page or public page?
408
+ if($isadminpage){
409
+ // is being called by comment_text filter so expecting just content
410
+ return $commentcontent;
411
+ } else {
412
+ // called from comments_array filter so expecting array of objects
413
+ return $new_commentarray;
414
  }
 
415
  }
416
 
417
  // set up default values
images/littleheartplus.gif ADDED
Binary file
js/adminremoveluv.js ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // removeluv link click action
2
+ jQuery(document).ready(function($) {
3
+ $('a.removeluv').click(function(){
4
+ var data = {
5
+ action: 'removeluv'
6
+ };
7
+ var vars = $(this).attr('class').split(':');
8
+ data.c = vars[1];
9
+ data._wpnonce = vars[2];
10
+ jQuery.post(ajaxurl, data, function(response) {
11
+ if(response == '0'){
12
+ alert('Luv meta does not exist');
13
+ return;
14
+ }
15
+ var stuff = response.split('*');
16
+ var cid = stuff[0];
17
+ var js = stuff[1];
18
+ var del_status =(new Function("return " + js))();
19
+ var statuscode = del_status.meta[0].status;
20
+ if(statuscode == 200){
21
+ var msg = 'Luv removed from WP DB and from ComLuv.com';
22
+ } else {
23
+ var msg = 'had a booboo :(';
24
+ }
25
+
26
+ $('#comment-'+cid+' td.comment .cluv').text(msg).fadeOut("slow").fadeIn("slow");
27
+ $('#comment-'+cid+' span.Remove-luv').text('');
28
+
29
+ });
30
+
31
+ return false;
32
+ });
33
+ });
js/commentluv.js CHANGED
@@ -1,4 +1,4 @@
1
- // commentluv.js 2.7
2
  (function($) {
3
  $(document).ready(function(){
4
  // get form object that is parent of textarea named "comment"
@@ -94,7 +94,12 @@
94
  $('#heart_tip_big').hoverIntent({over:do_nowt,out: heart_small, interval : 50, timeout: 350});
95
  var linkspan = $(this).parents(".cluv");
96
  var link = $(linkspan).find("a:first").attr("href");
97
- var url = cl_settings['api_url'] + "?type=info&refer=" + cl_settings['refer'] + '&version='+ cl_settings['cl_version'] + '&callback=?' + "&url=" + link ;
 
 
 
 
 
98
  do_info(url);
99
  }
100
  function heart_small(){
@@ -156,6 +161,7 @@
156
  $('#lastposts').empty();
157
  // get if is a member and other meta data
158
  var ismember = data.meta[0].ismember;
 
159
  cl_settings['request_id'] = data.meta[0].request_id;
160
  cl_settings['alert_message'] = data.meta[0].alert_message;
161
  // add the returned data to select box (or div)
@@ -197,7 +203,8 @@ function clchoose(ptype,purl,pstr,pid,preq){
197
  $('input[name="request_id"]').val(preq);
198
  $('input[name="cl_type"]').val(ptype);
199
  $('#mylastpost a').attr("href",purl).text(pstr);
200
- $('input[name="cl_post"]').val('<a href="' + purl + '">' + pstr + '</a>');
 
201
  $('#mylastpost img').attr({src: cl_settings['images'] + ptype + '.gif',alt: ptype});
202
  if($('#luv').is(":checked")){
203
  $('input[name="cl_post"]').val('<a href="' + purl + '">' + pstr + '</a>');
1
+ // commentluv.js 2.8
2
  (function($) {
3
  $(document).ready(function(){
4
  // get form object that is parent of textarea named "comment"
94
  $('#heart_tip_big').hoverIntent({over:do_nowt,out: heart_small, interval : 50, timeout: 350});
95
  var linkspan = $(this).parents(".cluv");
96
  var link = $(linkspan).find("a:first").attr("href");
97
+ // get member id from last class of image
98
+ var memberid = $('img',this).attr('class').split(' ').slice(-1);
99
+ if(memberid != ''){
100
+ memberid = '&memberid='+memberid;
101
+ }
102
+ var url = cl_settings['api_url'] + "?type=info&refer=" + cl_settings['refer'] + '&version='+ cl_settings['cl_version'] + memberid + '&callback=?' + "&url=" + link ;
103
  do_info(url);
104
  }
105
  function heart_small(){
161
  $('#lastposts').empty();
162
  // get if is a member and other meta data
163
  var ismember = data.meta[0].ismember;
164
+ $('#cl_memberid').val(ismember);
165
  cl_settings['request_id'] = data.meta[0].request_id;
166
  cl_settings['alert_message'] = data.meta[0].alert_message;
167
  // add the returned data to select box (or div)
203
  $('input[name="request_id"]').val(preq);
204
  $('input[name="cl_type"]').val(ptype);
205
  $('#mylastpost a').attr("href",purl).text(pstr);
206
+ $('input[name="cl_post_title"]').val( pstr );
207
+ $('input[name="cl_post_url"]').val(purl);
208
  $('#mylastpost img').attr({src: cl_settings['images'] + ptype + '.gif',alt: ptype});
209
  if($('#luv').is(":checked")){
210
  $('input[name="cl_post"]').val('<a href="' + purl + '">' + pstr + '</a>');
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: @commentluv (concept & coding)
3
  Donate link:http://comluv.com/about/donate
4
  Tags: commentluv, comments, last blog post, linkluv
5
- Requires at least: 2.8
6
- Tested up to: 2.9.2
7
- Stable tag: 2.7.69
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
 
@@ -30,7 +30,7 @@ WordpressMu : Same as above (do not place in mu-plugins)
30
 
31
  = Does this plugin add any database tables? =
32
 
33
- No. The link and a small bit of associated data is appended to the comment content at the time of submission
34
 
35
  = Will this plugin work with Disqus/Intense Debate/js-kit? =
36
 
@@ -41,12 +41,34 @@ Intense Debate comments have a commentluv plugin built in. Just enable from your
41
  You can submit a support ticket at http://comluv.com
42
 
43
  == Screenshots ==
 
44
  1. settings page
45
 
46
  2. in use
47
 
 
 
 
 
48
  == ChangeLog ==
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  = 2.769 =
51
  * Modified hidden post fields so only URL and title sent instead of html A href link
52
  * Modified javascript to take account of new hidden fields.
2
  Contributors: @commentluv (concept & coding)
3
  Donate link:http://comluv.com/about/donate
4
  Tags: commentluv, comments, last blog post, linkluv
5
+ Requires at least: 2.9.2
6
+ Tested up to: 3.0 RC1
7
+ Stable tag: 2.80
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
 
30
 
31
  = Does this plugin add any database tables? =
32
 
33
+ No. The link and associated data is saved to the comment meta table
34
 
35
  = Will this plugin work with Disqus/Intense Debate/js-kit? =
36
 
41
  You can submit a support ticket at http://comluv.com
42
 
43
  == Screenshots ==
44
+
45
  1. settings page
46
 
47
  2. in use
48
 
49
+ 3. comments admin
50
+
51
+ 4. edit post comments
52
+
53
  == ChangeLog ==
54
 
55
+ = 2.80 =
56
+ * Wordpress 3.0 Compatible
57
+ * Use comments meta table instead of hard coding into the comment content
58
+ * Drastically improved commmunication with API for comment status changes
59
+ * Near 100% accuracy for API to identify members links for info panel
60
+ * New heart icon for registered members. Improves hover rates.
61
+ * Removed depreciated function to clean old style additional data
62
+ * Added link to remove someones luvlink data in the comments admin page
63
+ * Dutch Translation by Rene wppg.me
64
+ * Added comments_array filter to make Thesis behave
65
+ * Added check to see if link already added (WP 3.0 compatibility)
66
+ * thanks to @hishaman for helping the thesis testing
67
+ * Added code to settings manager to prevent viewing outside wordpress (and fixed the typo later, thanks speedforce.org)
68
+
69
+ = 2.7691 =
70
+ * bugfix : choosing a link from an additional url's posts would result in wrong link being included
71
+
72
  = 2.769 =
73
  * Modified hidden post fields so only URL and title sent instead of html A href link
74
  * Modified javascript to take account of new hidden fields.
screenshot-1.jpg DELETED
Binary file
screenshot-1.png ADDED
Binary file
screenshot-2.jpg DELETED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
screenshot-4.png ADDED
Binary file