CommentLuv - Version 2.7

Version Description

Download this release

Release Info

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

Code changes from version 1.0 to 2.7

README.txt DELETED
@@ -1,122 +0,0 @@
1
- === WP Twitip ID ===
2
- Tags: twitter, tweet, integration, comment,
3
- Contributors: @commentluv(coding), @styletime(beta testing), @problogger(inspiration), @saphod(update_options), @clearskynet(db table creation)
4
- Requires at least: 2.6.3
5
- Tested up to: 2.7
6
- Stable tag: 1.0
7
-
8
- WP Twitip ID adds a field to the comment form for a user to add their twitter username. Once published, their comment will display a link to follow them on twitter wherever you want by adding a line to your themes' comments.php
9
-
10
- == Details ==
11
-
12
- WP Twitip ID functionality:
13
-
14
- * Adds an extra field to the comment form for user to enter their twitter username
15
- * Echo out the twitter id associated with the comment being displayed
16
- * Echo out a html link pointing to the users twitter page using "Click Here To Follow Me On Twitter"
17
- * Display link as an image
18
- * Ouput just the @ username
19
- * Return the twitter id as a variable to be used by php
20
- * Automatically display Twitter: @username
21
- * Display html before the extra field
22
- * Display html after the extra field
23
- * Add a class name to the extra field
24
- * disable javascript field addition for manual form editing
25
-
26
-
27
- == Installation ==
28
-
29
- 1. Download the plugin archive and expand it (you've likely already done this).
30
- 2. Put the 'wp-twitip-id' folder and all files inside into your wp-content/plugins/ directory.
31
- 3. Go to the Plugins page in your WordPress Administration area and click 'Activate' for WP Twitip ID.
32
- 4. Go to the WP Twitip ID Options page (Settings > WP Twitip ID) to set where you want the field to appear (defaults to after the url field) and add your chosen anchor text or image url
33
-
34
-
35
- == Configuration ==
36
-
37
- Put field after object ID
38
- Enter the ID of the field or object that you want the extra field to be displayed after
39
- defaults to url
40
-
41
- Labels are before fields?
42
- If your comments.php file puts the label before the field check this box
43
- defaults to off
44
-
45
- Don't use Javascript
46
- If you edit your comments.php file and add a field manually, you need to select this (manual adding requires field to have name="atf_twitter_id")
47
- defaults to off
48
-
49
- HTML before field
50
- Custom html you want to add before the field is added
51
- defaults to <br/>
52
-
53
- HTML after Field
54
- Custom html you want to add after the field is added
55
- defaults to <br/><label for="atf_twitter_id">Twitter ID</label>
56
- (if you check labels are before fields, you can enter this html into the html before field
57
-
58
- Field class
59
- the class you want to apply to the field
60
- defaults to textarea
61
-
62
- Twitter Image URI
63
- Image url for image output
64
-
65
- Twitter anchor text
66
- Text to display in link for text output
67
-
68
- == Adding to your template ==
69
-
70
- Open your themes comments.php file and add this line
71
- if(function_exists(wp_twitip_id_show)) {
72
- wp_twitip_id_show("auto");
73
- }
74
-
75
- You can use "image" or "text" or "user"
76
-
77
- "image" = show linked image using image url in settings page
78
- "text" = show text link using anchor text in settings page
79
- "user" = show just the @username
80
- "return" = return the twitter id as a variable for use in custom php
81
- "auto" = show Twitter: @commentluv in a span with class twitter_id
82
-
83
- example:
84
- within the comments loop (foreach($comments as $comment)) I put this below the date output in comments.php
85
- <?php if(function_exists(wp_twitip_id_show)) {
86
- wp_twitip_id_show("auto");
87
- }?>
88
-
89
- "return" = return the twitter id to be used as a variable
90
- example:
91
- <?php if(function_exists(wp_twitip_id_show)) {
92
- $twitter=wp_twitip_id_show("return");
93
- if($twitter){
94
- // has a twitter id
95
- ?>I has a <a href="http://twitter.com/<?php echo $twitter;?>">Twitter Account</a>
96
- <?php }
97
-
98
-
99
- == Frequently Asked Questions ==
100
-
101
- = The added field doesn't look like the others on the form =
102
- Inspect the html of your form and see what class has been applied to the field and use that value in the settings page under "field class"
103
-
104
- = No field is being added =
105
- Make sure there are no carriage returns (new line breaks) in the code for html before and after field in the settings page
106
-
107
- = Can it work with logged on users? =
108
- Yes, as long as they comment at least once and add their ID to the field whilst logged out.
109
-
110
- = I was using the beta and now all the previous comments have lost their twitter link =
111
- The beta version saved the values differently. As long as the person makes another comment and add their ID then all comments by them using that email will be updated.
112
-
113
- = Do I have to use javascript to add the field? =
114
- No. You can manually add the field to your comment form and select the checkbox on the settings page to not use javascript. (the field needs to have name="atf_twitter_id")
115
-
116
- = Anything else? =
117
-
118
- Hope you enjoy this plugin!
119
-
120
- --Andy Bailey
121
-
122
- http://www.fiddyp.co.uk
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
commentluv-manager.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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">
9
+ <input type="hidden" name="submitted" value="1" />
10
+ <?php wp_nonce_field('commentluv-nonce');?>
11
+ <p><?php _e('This plugin takes the url from the comment form and tries to parse the feed of the site and display the last entry made.
12
+ If you have any questions, comments or if you have a good idea that you would like to see in the next version of CommentLuv, please visit http://comluv.com and let me know.',$this->plugin_domain);?></p>
13
+ <h3><?php _e('Display Options',$this->plugin_domain);?></h3>
14
+ <label for="cl_comment_text"><?php _e('Enter the text you want displayed in the comment',$this->plugin_domain);?></label> <br/>
15
+ <input type="text" size="50" name="cl_comment_text" value="<?php echo stripslashes($comment_text);?>"/>
16
+ <p>
17
+ <label for="cl_select_text"><?php _e('Text displayed in the select box',$this->plugin_domain);?></label> <br/>
18
+ <input type="text" size="50" name="cl_select_text" value="<?php echo stripslashes($select_text);?>"/>
19
+ </p><p>
20
+ <input type="checkbox" name="cl_default_on" <?php echo $default_on;?>/>
21
+ <label for="cl_default_on"><?php _e('CommentLuv on by default?',$this->plugin_domain);?></label>
22
+ </p><p>
23
+ <input type="checkbox" name="cl_heart_tip" <?php echo $heart_tip;?>/>
24
+ <label for="cl_heart_tip"><?php _e('Show heart on links?',$this->plugin_domain);?></label>
25
+ </p>
26
+ <p>
27
+ <input type="checkbox" name="cl_use_template" <?php echo $use_template;?>/>
28
+ <label for="cl_use_template"><?php _e('Use template insert to show badge and checkbox?',$this->plugin_domain);?> ( &lt;?php cl_show_badge(); ?&gt; )</label>
29
+ </p>
30
+ <h3><?php _e('Display Badge',$this->plugin_domain);?></h3>
31
+ <p><?php _e('Many thanks to <a href="http://byteful.com">Byteful Traveller</a> for creating these images.',$this->plugin_domain);?></p>
32
+ <table class="form-table">
33
+ <tr>
34
+ <td><?php _e('Choose badge to display','commentluv')?> </td>
35
+
36
+ <td><label><input type="radio" <?php echo $badge1; ?> name="cl_badge" value="ACL88x31-black2.gif"><img src="<?php echo $this->plugin_url;?>images/ACL88x31-black2.gif"/></label></td>
37
+ <td><label><input type="radio" <?php echo $badge2; ?> name="cl_badge" value="ACL88x31-white2.gif"><img src="<?php echo $this->plugin_url;?>images/ACL88x31-white2.gif"/></label></td>
38
+ <td><label><input type="radio" <?php echo $badge3; ?> name="cl_badge" value="CL91x17-black2.gif"><img src="<?php echo $this->plugin_url;?>images/CL91x17-black2.gif"/></label></td>
39
+ <td><label><input type="radio" <?php echo $badge4; ?> name="cl_badge" value="CL91x17-white2.gif"><img src="<?php echo $this->plugin_url;?>images/CL91x17-white2.gif"/></label></td>
40
+ <td><label><input type="radio" <?php echo $badge5; ?> name="cl_badge" value="nothing.gif"><?php _e('Show nothing',$this->plugin_domain);?></label></td>
41
+ </tr></table>
42
+ <table class="form-table">
43
+ <tr><td><label><input type="radio" <?php echo $badge_text;?> name="cl_badge" value="text"><?php _e('Show text','commentluv')?></label> <input class="form-table" type="text" name="cl_show_text" value="<?php echo stripslashes($show_text);?>"></input></td><td></td><td></td><td></td><td><label><?php _e('Prepend html before badge or text (optional)',$this->plugin_domain);?></label><input class="form-table" type="text" name="cl_prepend" value="<?php echo stripslashes($prepend);?>"></input></tr>
44
+ </table> <p></p>
45
+ <h3><?php _e('CommentLuv Member Area',$this->plugin_domain);?></h3>
46
+ <p><?php _e('If you register your site for free at <a href="http://comluv.com">ComLuv.com</a> you will be able to open up lots of features that are for members only like link tracking so you can see which of the comments you make on CommentLuv blogs are getting the last blog post clicked and the ability to send back more than just blog posts. You can even create your own WP2.7 blog there with commentluv pre-installed!.',$this->plugin_domain);?></p>
47
+
48
+ <h3><?php _e('Technical Settings',$this->plugin_domain);?></h3>
49
+ <small><?php _e('In most cases you shouldn\'t need to change these settings unless you have a customized comment form',$this->plugin_domain);?></small>
50
+ <table class="form-table">
51
+ <tbody>
52
+ <tr>
53
+ <td><?php _e('Authors Name field name',$this->plugin_domain);?></td>
54
+ <td><input type="text" value="<?php echo $author_name;?>" name="cl_author_name"/></td>
55
+ </tr>
56
+ <tr>
57
+ <td><?php _e('Email field name',$this->plugin_domain);?></td>
58
+ <td><input value="<?php echo $email_name;?>" type="text" name="cl_email_name"/></td>
59
+ </tr>
60
+ <tr>
61
+ <td><?php _e('Authors URL field name',$this->plugin_domain);?></td>
62
+ <td><input value="<?php echo $url_name;?>" type="text" name="cl_url_name"/></td>
63
+ </tr>
64
+ <tr>
65
+ <td><?php _e('Comment Text Area name',$this->plugin_domain);?></td>
66
+ <td><input value="<?php echo $comment_name;?>" type="text" name="cl_comment_name"/></td>
67
+ </tr>
68
+ </tbody></table>
69
+ <div class="submit"><input type="submit" name="Submit" value="update" /></div>
70
+
71
+
72
+ </form>
73
+ <div style=" background-color: #ff0000; width: 200px; text-align: center;"><?php _e('Reset to Default Settings',$this->plugin_domain);?>
74
+ <form action="<?php echo $action_url ?>" method="POST">
75
+
76
+ <?php wp_nonce_field('commentluv-nonce');?>
77
+ <input type="hidden" name="reset" value="reset"/>
78
+ <?php $javamsg = __('Are you sure you want to reset your settings? Press OK to continue',$this->plugin_domain);?>
79
+ <input type="submit" style="width: 150px;" onclick="<?php echo 'if(confirm(\''.$javamsg.'\') != true) { return false; } else { return true; } ';?>" value="reset" name="submit"/></div>
80
+ </form>
81
+ </div>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ <?php // end ?>
commentluv.php ADDED
@@ -0,0 +1,444 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
6
+ Author: Andy Bailey
7
+ Author URI: http://fiddyp.comluv.com/
8
+
9
+ 26 Apr 2009 - Start the new version using a class and updated localization (thanks Vladimir Prelovac for your great book on Wordpress Plugin Development!)
10
+ 05 Jun 2009 - Finalized last functions and integrated API. big up to @wpmuguru for API coding!
11
+ */
12
+ // Avoid name collision
13
+ if ( !class_exists('commentluv') ) {
14
+ // let class begin
15
+ class commentluv
16
+ {
17
+ //localization domain
18
+ public $plugin_domain = 'commentluv';
19
+ public $plugin_url;
20
+ public $db_option = 'commentluv_options';
21
+ public $cl_version = 270;
22
+ public $api_url;
23
+
24
+ //initialize the plugin
25
+ function commentluv()
26
+ {
27
+ global $wp_version, $pagenow;
28
+ // pages where commentluv needs translation
29
+ $local_pages = array('plugins.php','commentluv.php');
30
+ // check if translation needed on current page
31
+ if (in_array($pagenow, $local_pages) || in_array($_GET['page'],$local_pages)){
32
+ $this->handle_load_domain();
33
+ }
34
+ $exit_msg = __('CommentLuv requires Wordpress 2.6.5 or newer.',$this->plugin_domain).
35
+ '<a href="http://codex.wordpress.org/Upgrading_Wordpress">'.
36
+ __('Please Update!', $this->plugin_domain).
37
+ '</a>';
38
+
39
+ // can you dig it?
40
+ if (version_compare($wp_version,"2.6.5","<") )
41
+ {
42
+ exit ($exit_msg); // no diggedy
43
+ }
44
+
45
+ // action hooks
46
+ $this->plugin_url = trailingslashit( WP_PLUGIN_URL.'/'. dirname( plugin_basename(__FILE__) ));
47
+ $this->api_url = 'http://api.comluv.com/cl_api/commentluvapi.php';
48
+ add_action('admin_menu', array(&$this, 'admin_menu'));
49
+ add_action('template_redirect', array(&$this, 'commentluv_scripts')); // template_redirect always called when page is displayed to user
50
+ add_action('wp_head',array(&$this, 'commentluv_style')); // add style sheet to header
51
+ add_action('wp_set_comment_status',array(&$this,'update_cl_status'), 1, 3); // call when status of comment gets changed
52
+ add_action('comment_post',array(&$this,'update_cl_status'), 2, 3); // call when comment gets posted
53
+ add_action('comment_form',array(&$this, 'add_fields')); // add hidden fields during comment form display time
54
+ 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
55
+ add_filter('comment_text', array(&$this,'do_shortcode')); // replace inserted data with hidden span on display time of comment
56
+ add_filter('pre_comment_content',array(&$this,'cl_post'),10); // extract extra fields data and insert data to end of comment
57
+ add_filter('get_comment_excerpt',array(&$this,'excerpt_tag_remove')); // remove the tags when get comment excerpt is used
58
+ add_filter('comment_excerpt',array(&$this,'excerpt_tag_remove')); // remove the tags when comment excerpt is used
59
+
60
+ }
61
+
62
+ // hook the options page
63
+ function admin_menu(){
64
+ $menutitle = '<img src="' . $this->plugin_url.'images/littleheart.gif" alt=""/> ';
65
+ $menutitle .= 'CommentLuv';
66
+ add_options_page('CommentLuv Settings', $menutitle, 8, basename(__FILE__), array(&$this, 'handle_options'));
67
+ }
68
+ // add the settings link
69
+ function commentluv_action ($links, $file){
70
+ $this_plugin = plugin_basename(__FILE__);
71
+ if ($file == $this_plugin){
72
+ $links[] = "<a href='options-general.php?page=commentluv.php'>" . '<img src="' . $this->plugin_url.'images/littleheart.gif" alt=""/> ' . __('Settings', $this->plugin_domain) . "</a>";
73
+ }
74
+ return $links;
75
+ }
76
+ // hook the template_redirect for inserting style and javascript (using wp_head would make it too late to add dependencies)
77
+ function commentluv_scripts(){
78
+ // only load scripts if on a single page
79
+ if(is_single()){
80
+ wp_enqueue_script('jquery');
81
+ global $wp_version;
82
+ // see if hoverintent library is already included (2.7 >)
83
+ if (version_compare($wp_version,"2.7","<")){
84
+ wp_enqueue_script('hoverIntent','/'.PLUGINDIR.'/'.dirname( plugin_basename(__FILE__)).'/js/hoverIntent.js',array('jquery'));
85
+ } else {
86
+ wp_enqueue_script('hoverIntent','/'.WPINC.'/js/hoverIntent.js',array('jquery'));
87
+ }
88
+ wp_enqueue_script('commentluv',$this->plugin_url.'js/commentluv.js',array('jquery'));
89
+ // get options
90
+ $options=$this->get_options();
91
+ foreach ($options as $key =>$value){
92
+ $$key = $value;
93
+ }
94
+ // prepare options
95
+ $default_on = $default_on == 'on'? 'checked':'';
96
+ // untick the box if user is admin
97
+ global $user_ID;
98
+ if( $user_ID ) {
99
+ if( current_user_can('create_users') ) {
100
+ $default_on = '';
101
+ }
102
+ }
103
+ $badge = $this->plugin_url . "images/" . $badge;
104
+ $badge_text = $options['badge'] == 'text'?'on':'';
105
+ // insert options to header
106
+ wp_localize_script('commentluv','cl_settings',array(
107
+ 'name'=>$author_name,
108
+ 'url'=>$url_name,
109
+ 'comment'=>$comment_name,
110
+ 'email'=>$email_name,
111
+ 'prepend'=>$prepend,
112
+ 'badge'=>$badge,
113
+ 'show_text'=>$show_text,
114
+ 'badge_text'=>$badge_text,
115
+ 'heart_tip'=>$heart_tip,
116
+ 'default_on'=>$default_on,
117
+ 'select_text'=>$select_text,
118
+ 'cl_version'=>$this->cl_version,
119
+ 'images'=>$this->plugin_url . 'images/',
120
+ 'api_url'=>$this->api_url
121
+ ));
122
+ }
123
+ }
124
+ // hook the head function for adding stylesheet
125
+ function commentluv_style (){
126
+ echo '<link rel="stylesheet" href="'.$this->plugin_url.'style/cl_style.css" type="text/css" />';
127
+ }
128
+
129
+ // get plugin options
130
+ function get_options(){
131
+ // default values
132
+ $options = array(
133
+ 'comment_text' => '[name]&#180;s last [type] ..[lastpost]',
134
+ 'select_text' => 'choose a different post to show',
135
+ 'default_on' => 'on',
136
+ 'heart_tip' => 'on',
137
+ 'use_template' => '',
138
+ 'badge' => 'CL91x17-white2.gif',
139
+ 'show_text' => 'CommentLuv Enabled',
140
+ 'author_name' => 'author',
141
+ 'url_name' => 'url',
142
+ 'comment_name' => 'comment',
143
+ 'email_name' => 'email',
144
+ 'prepend' => ''
145
+ );
146
+ // get saved options unless reset button was pressed
147
+ $saved = '';
148
+ if(!isset($_POST['reset'])){
149
+ $saved = get_option($this->db_option);
150
+ }
151
+
152
+ // assign values
153
+ if (!empty($saved))
154
+ {
155
+ foreach ($saved as $key =>$option){
156
+ $options[$key] = $option;
157
+ }
158
+ }
159
+ // update the options if necessary
160
+ if ($saved != $options){
161
+ update_option($this->db_option,$options);
162
+ }
163
+ // return the options
164
+ return $options;
165
+ }
166
+
167
+ // handle saving and displaying options
168
+ function handle_options()
169
+ {
170
+ $options = $this->get_options();
171
+ if ( isset($_POST['submitted']) )
172
+ {
173
+
174
+ // initialize the error class
175
+ $errors = new WP_Error();
176
+
177
+ // check security
178
+ check_admin_referer('commentluv-nonce');
179
+
180
+ $options = array();
181
+ $options['comment_text']=htmlspecialchars($_POST['cl_comment_text']);
182
+ $options['select_text']=htmlspecialchars($_POST['cl_select_text']);
183
+ $options['default_on']=$_POST['cl_default_on'];
184
+ $options['heart_tip']=$_POST['cl_heart_tip'];
185
+ $options['badge']=$_POST['cl_badge'];
186
+ $options['show_text']=htmlspecialchars($_POST['cl_show_text']);
187
+ $options['prepend']=htmlspecialchars($_POST['cl_prepend']);
188
+ $options['author_name']=$_POST['cl_author_name'];
189
+ $options['url_name']=$_POST['cl_url_name'];
190
+ $options['comment_name']=$_POST['cl_comment_name'];
191
+ $options['email_name']=$_POST['cl_email_name'];
192
+
193
+ // check for errors
194
+ if( count($errors->errors) > 0 ){
195
+ echo '<div class="error"><h3>';
196
+ _e('There were errors with your chosen settings',$this->plugin_domain);
197
+ echo '</h3>';
198
+ foreach( $errors->get_error_messages() as $message ){
199
+ echo $message;
200
+ }
201
+ echo '</div>';
202
+ } else {
203
+ //every-ting cool mon
204
+ update_option($this->db_option, $options);
205
+ echo '<div class="updated fade"><p>Plugin settings saved.</p></div>';
206
+ }
207
+
208
+ }
209
+ // loop through each option and assign it as key=value
210
+ foreach ($options as $key =>$value){
211
+ $$key = $value;
212
+ }
213
+ // set value to checked if option is on (for showing correct status of checkbox and radio button in settings page)
214
+ $default_on = $options['default_on'] == 'on'?'checked':'';
215
+ $heart_tip = $options['heart_tip'] == 'on'?'checked':'';
216
+ $badge1 = $options['badge'] == 'ACL88x31-black2.gif'?'checked':'';
217
+ $badge2 = $options['badge'] == 'ACL88x31-white2.gif'?'checked':'';
218
+ $badge3 = $options['badge'] == 'CL91x17-black2.gif'?'checked':'';
219
+ $badge4 = $options['badge'] == 'CL91x17-white2.gif'?'checked':'';
220
+ $badge5 = $options['badge'] == 'nothing.gif'?'checked':'';
221
+ $use_template = $options['use_template'] == 'on'?'checked':'';
222
+ $badge_text = $options['badge'] == 'text'?'checked':'';
223
+
224
+ // url for form submit
225
+ $action_url = $_SERVER['REQUEST_URI'];
226
+ include('commentluv-manager.php');
227
+ }
228
+ // shortcode for showing badge and drop down box
229
+ function display_badge(){
230
+ if(is_single()){
231
+ $options = get_option($this->db_option);
232
+ // choose as image or as text
233
+ $badge_text = $options['badge'] == 'text'?'on':'';
234
+ $default_on = $options['default_on'] == 'on'?'checked':'';
235
+ // untick the box if user is admin
236
+ global $user_ID;
237
+ if( $user_ID ) {
238
+ if( current_user_can('create_users') ) {
239
+ $default_on = '';
240
+ }
241
+ }
242
+ $options['badge'] = $this->plugin_url . 'images/' . $options['badge'];
243
+ if($badge_text == ''){
244
+ $badge='<a href="http://comluv.com" target="_new"><img src="' . $options['badge'] . '" border=0 alt="' . $options['show_text'] .'" title="'.$options['show_text'].'"/></a>';
245
+ } else {
246
+ $badge=$options['badge_text'];
247
+ }
248
+ echo '<div id="commentluv">' . $options['prepend'] . '<input type="checkbox" id="doluv" name="doluv" ' .
249
+ $default_on . ' style="width:25px;"></input><span id="mylastpost" style="clear: both">' .
250
+ $badge . '</span><img class="clarrow" id="showmore" src="' .
251
+ $this->plugin_url . 'images/down-arrow.gif" alt="show more" style="display:none;"/></div><div id="lastposts" style="display: none;"></div>';
252
+ }
253
+ }
254
+ // hook the comment form to add fields for url for logged in users
255
+ function add_fields($id){
256
+ $options = get_option($this->db_option);
257
+ $cl_author_id=$options['author_name'];
258
+ $cl_site_id=$options['url_name'];
259
+
260
+ if (is_user_logged_in()){
261
+ // get options values and insert as hidden fields
262
+ global $userdata;
263
+ get_currentuserinfo();
264
+ $author=$userdata->display_name;
265
+ $userid=$userdata->ID;
266
+ $url=$userdata->user_url;
267
+ // check for MU blog
268
+ if( function_exists( 'is_site_admin' ) ) {
269
+ if(!$url || $url=="http://"){
270
+ $userbloginfo = get_blogs_of_user($userid,1);
271
+ $url=$userbloginfo[1]->siteurl;
272
+ }
273
+ }
274
+
275
+ echo "<input type='hidden' id='$cl_author_id' name='$cl_author_id' value='$author' />";
276
+ echo "<input type='hidden' id='$cl_site_id' name='$cl_site_id' value='$url' />";
277
+ }
278
+ // add hidden fields for holding information about type,choice,html and request for every user
279
+ echo '<input type="hidden" name="cl_type" />';
280
+ echo '<input type="hidden" name="choice_id" />';
281
+ echo '<input type="hidden" name="request_id" />';
282
+ echo '<input type="hidden" name="cl_post" id="cl_post"/>';
283
+ // check if using php call comments.php or not
284
+ if($options['use_template']==''){
285
+ $this->display_badge();
286
+ }
287
+ return $id;
288
+ }
289
+
290
+ // hook the pre_comment_content to add the link using a tag after the user submits their comment but before it gets saved in db
291
+ function cl_post($commentdata){
292
+ if( isset($_POST['cl_post']) && $_POST['request_id'] !='' && is_numeric($_POST['choice_id']) && isset($_POST['cl_type']) ) {
293
+ // get values posted
294
+ $luvlink = $_POST['cl_post'];
295
+ if(strstr($luvlink,"commentluv.com/error-check") || $_POST['request_id'] == 0){
296
+ return $commentdata;
297
+ }
298
+ $request_id = $_POST['request_id'];
299
+ $choice_id = $_POST['choice_id'];
300
+ $cl_type = $_POST['cl_type'];
301
+ // insert identifying data to end of comment
302
+ $commentdata.= "\n[rq=$request_id,$choice_id,$cl_type][/rq]$luvlink";
303
+ }
304
+ return $commentdata;
305
+ }
306
+ // hook the set comment status action
307
+ function update_cl_status($cid, $status) {
308
+ // get comment stuff from id
309
+ if($status != 'spam') {
310
+ if($status != 'delete') {
311
+ $status = 'approve';
312
+ }
313
+ $comment = get_comment($cid);
314
+ if(strpos($comment->comment_content,"[rq=")){
315
+ // comment can be approved or deleted in the comluv db
316
+ $url = $this->api_url ."?type={$status}&url=";
317
+ // get the added bits from comment
318
+ $commentcontent = $comment->comment_content;
319
+ $start = strpos($commentcontent,'[rq=');
320
+ $end = strpos($commentcontent,'[/rq]');
321
+ $params = substr($commentcontent,$start+4,$end-$start-5);
322
+ $arr = explode(",",$params);
323
+ // construct url with added params for approving comment to comluv
324
+ $url.=$comment->comment_author_url . "&request_id=" . $arr[0] . "&post_id=" . $arr[1] . "&version=" . $this->cl_version;
325
+ // call the url ..
326
+ if(function_exists("curl_init")){
327
+ //setup curl values
328
+ $curl=curl_init();
329
+ curl_setopt($curl,CURLOPT_URL,$url);
330
+ curl_setopt($curl,CURLOPT_HEADER,0);
331
+ curl_setopt($curl,CURLOPT_RETURNTRANSFER,TRUE);
332
+ curl_setopt($curl,CURLOPT_TIMEOUT,7);
333
+ $content=curl_exec($curl);
334
+ if(!curl_error($curl)){
335
+ $data=json_decode($content);
336
+ curl_close($curl);
337
+ if($data->status != 200){
338
+ // unsuccessful confirmation.
339
+ // have a tantrum here if you want.
340
+ }
341
+ }
342
+ } elseif(ini_get('allow_url_fopen')){
343
+ $result = @file_get_contents($url);
344
+ }
345
+ } // end if comment content contains a rq var
346
+ }
347
+ }
348
+
349
+ // use my own shortcode that was inserted at submission time and hide the params
350
+ function do_shortcode($commentcontent) {
351
+ if(strpos($commentcontent,"[rq=")){
352
+ // get bit that was added
353
+ $start = strpos($commentcontent,'[rq=');
354
+ $end = strpos($commentcontent,'[/rq]') + 5;
355
+ $params = substr($commentcontent,$start,$end-$start);
356
+ $luvlink = substr($commentcontent,$end);
357
+ // insert hidden span for params and chop off luvlink for now
358
+ $commentcontent = substr($commentcontent,0,$start) . '<span class="cl_hidden" style="display:none;">' . $params . '</span>';
359
+ // get name and site of comment author
360
+ $options = get_option($this->db_option);
361
+ global $comment;
362
+ $author_name = $comment->comment_author;
363
+ $author_url = $comment->comment_author_url;
364
+ // get array of params
365
+ $params = explode(",",substr($params,4,-6));
366
+ // get and prepare the text specified by the user
367
+ $prepend_text = $options['comment_text'];
368
+ $search = array('[name]','[type]','[lastpost]');
369
+ $replace = array($author_name,$params[2],$luvlink);
370
+ $inserted = str_replace($search,$replace,$prepend_text);
371
+ // append our doobries on the end of the hidden span
372
+ $commentcontent .= '<span class="cluv">'.$inserted;
373
+ // do heart info
374
+ if($options['heart_tip'] == 'on'){
375
+ $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>';
376
+ }
377
+ $commentcontent .= '</span>';
378
+ }
379
+ return $commentcontent;
380
+ }
381
+ // hook the get_comment_excerpt filter to remove tags
382
+ function excerpt_tag_remove($theexcerpt){
383
+ if(strpos($theexcerpt,"[rq=")){
384
+ $start = strpos($theexcerpt,'[rq=');
385
+ if(strpos($theexcerpt,"[/rq]")) {
386
+ $end=strpos($theexcerpt,'[/rq]') + 5;
387
+ $params= substr($theexcerpt,$start,$end-$start);
388
+ $theexcerpt = str_replace($params,"",$theexcerpt);
389
+ } else {
390
+ $theexcerpt = substr($theexcerpt,0,$start) . '...';
391
+ }
392
+ }
393
+ return $theexcerpt;
394
+ }
395
+
396
+ // set up default values
397
+ function install()
398
+ {
399
+ // set default options
400
+ $this->get_options();
401
+ }
402
+
403
+ // Localization support
404
+ function handle_load_domain()
405
+ {
406
+ // get current language
407
+ $locale = get_locale();
408
+
409
+ // locate translation file
410
+ $mofile = WP_PLUGIN_DIR.'/'.plugin_basename(dirname(__FILE__)).'/lang/' . $this->plugin_domain . '-' . $locale . '.mo';
411
+
412
+ // load translation
413
+ load_textdomain($this->plugin_domain, $mofile);
414
+ }
415
+
416
+
417
+
418
+ }
419
+ }
420
+
421
+ // start commentluv class engines
422
+ if ( class_exists('commentluv') ) :
423
+ $commentluv = new commentluv();
424
+
425
+ // confirm warp capability
426
+ if (isset($commentluv) )
427
+ {
428
+ // engage
429
+ register_activation_hook( __FILE__, array(&$commentluv,'install') );
430
+
431
+ }
432
+ endif;
433
+
434
+ // function for template call
435
+ function cl_display_badge(){
436
+ $temp = new commentluv();
437
+ $temp->display_badge();
438
+ }
439
+
440
+
441
+
442
+
443
+
444
+ ?>
images/ACL88x31-black2.gif ADDED
Binary file
images/ACL88x31-white2.gif ADDED
Binary file
images/CL91x17-black2.gif ADDED
Binary file
images/CL91x17-white2.gif ADDED
Binary file
images/blog.gif ADDED
Binary file
images/digg.gif ADDED
Binary file
images/down-arrow.gif ADDED
Binary file
images/littleheart.gif ADDED
Binary file
images/loader.gif ADDED
Binary file
images/twitter.gif ADDED
Binary file
images/undefined.gif ADDED
Binary file
js/addtwitterfield.js DELETED
@@ -1,59 +0,0 @@
1
- // javascript for wp-twitip-id 1.0
2
- function addtwitterfield (atf_afterID,atf_prehtml,atf_psthtml,atf_field_class,atf_nolabels,atf_swaplabel,atf_nojava){
3
- // use jquery to add a field to the comment form
4
- jQuery.noConflict();
5
- jQuery(document).ready(function(){
6
- if(jQuery("#" + atf_afterID).length < 1) { return }
7
- if(atf_nojava != "on"){
8
- // get tabindex
9
- var tabIndex = parseInt(jQuery("#" + atf_afterID).attr("tabindex")) + 1;
10
- // add the field
11
- var formObj = jQuery("textarea[name='comment']").parents("form"); // get form object that is parent of textarea named "comment"
12
- if(atf_nolabels!="on" && atf_swaplabel != "on") {
13
- var objafter = "label[for='" + atf_afterID + "']";
14
- } else {
15
- var objafter = "#" + atf_afterID;
16
- }
17
-
18
- jQuery(objafter,formObj).after(atf_prehtml + "<input type=\"text\" name=\"atf_twitter_id\" class=\"" + atf_field_class + "\" tabindex=\"" + tabIndex + "\" ></input>" + atf_psthtml);
19
- }
20
- // monitor twitter field so can be added to cookie
21
- var fieldobj = jQuery("input[name='atf_twitter_id']");
22
- jQuery(fieldobj).blur(function(){
23
- atf_createCookie('atf_cookie',jQuery(this).val(),60);
24
- });
25
- // add value if cookie exists
26
- var x = atf_readCookie('atf_cookie');
27
- if(x) {
28
- jQuery(fieldobj).val(x);
29
- }
30
-
31
- });
32
-
33
- // cookie stuff mmmmmm cookies....
34
- //http://www.quirksmode.org/js/cookies.html
35
- function atf_createCookie(name,value,days) {
36
- if (days) {
37
- var date = new Date();
38
- date.setTime(date.getTime()+(days*24*60*60*1000));
39
- var expires = "; expires="+date.toGMTString();
40
- }
41
- else { var expires = ""; }
42
- document.cookie = name+"="+value+expires+"; path=/";
43
- }
44
-
45
- function atf_readCookie(name) {
46
- var nameEQ = name + "=";
47
- var ca = document.cookie.split(';');
48
- for(var i=0;i < ca.length;i++) {
49
- var c = ca[i];
50
- while (c.charAt(0)==' ') {c = c.substring(1,c.length);}
51
- if (c.indexOf(nameEQ) == 0){ return c.substring(nameEQ.length,c.length);}
52
- }
53
- return null;
54
- }
55
-
56
- function atf_eraseCookie(name) {
57
- createCookie(name,"",-1);
58
- }
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/commentluv.js ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // commentluv.js 2.7
2
+ jQuery.noConflict();
3
+ (function($) {
4
+ $(document).ready(function(){
5
+ // get form object that is parent of textarea named "comment"
6
+ var formObj = $("#cl_post").parents("form");
7
+
8
+ // set url, email, comment and author field objects
9
+ var urlObj = cl_settings['urlObj'] = $("input[name='" + cl_settings['url'] + "']",formObj);
10
+ var comObj = cl_settings['comObj'] = $("textarea[name='" + cl_settings['comment'] + "']",formObj);
11
+ var autObj = cl_settings['autObj'] = $("input[name='" + cl_settings['name'] + "']",formObj);
12
+ var emaObj = cl_settings['emaObj'] = $("input[name='" + cl_settings['email'] + "']",formObj);
13
+ // use image or text
14
+ if(cl_settings['badge_text'] == ''){
15
+ cl_settings['badge']='<img src="' + cl_settings['badge'] + '" border=0 alt="' + cl_settings['show_text'] +'"/>';
16
+ } else {
17
+ cl_settings['badge']=cl_settings['badge_text']
18
+ }
19
+ // set the event listener for the comment text area focus
20
+ $(comObj).focus(function(){
21
+ $('#lastposts').hide();
22
+ cl_dostuff();
23
+ });
24
+ // set the event listener for the show more image
25
+ $("#showmore").click(function(){
26
+ // hide drop down box for click outside
27
+ $(document.body).click(function(){
28
+ $('#lastposts').hide();
29
+ });
30
+ $("#lastposts").slideDown(1000);
31
+ });
32
+ // set the event listener for change of url
33
+ $(urlObj).change(function(){
34
+ $(comObj).focus(function(){
35
+ cl_dostuff();
36
+ });
37
+ });
38
+ // set the event listener for the click action
39
+ $('.cluv a').click(function(){
40
+
41
+ // get request_id from within hidden span and url that was clicked
42
+ var str = $(this).parents("span").prev("span").text();
43
+ var params = str.substr(4).split(",");
44
+ var url=$(this).attr('href');
45
+ // set link to open in a new window
46
+ $(this).attr("target","_blank");
47
+ var addit= "?type=click&request_id=" + params[0] + "&url=" + url + "&callback=?";
48
+ var clurl=cl_settings['api_url'] + addit;
49
+ // call api, don't worry about returned data
50
+ $.getJSON(clurl);
51
+ return true;
52
+ });
53
+ // set the event listener for the click of the checkbox
54
+ $('#doluv').click(function(){
55
+ $('#lastposts').hide();
56
+ if($(this).is(":checked")){
57
+ // was unchecked, now is checked
58
+ $('#mylastpost').fadeTo("fast",1);
59
+ cl_dostuff();
60
+ } else {
61
+ // was checked, user unchecked it so empty hidden fields in form
62
+ $('#cl_post').val("");
63
+ $('input[name="cl_type"]').val("");
64
+ $('input[name="request_id"]').val("");
65
+ $('input[name="choice_id"]').val("");
66
+ $('#mylastpost').fadeTo("slow",0.3);
67
+ }
68
+ });
69
+ // set hover event for heart tip
70
+ if(cl_settings['heart_tip'] == "on"){
71
+ $('.heart_tip_box').hoverIntent({over:heart_big,out: heart_small,interval : 250,timeout: 350});
72
+ }
73
+ function heart_big(){
74
+ $(this).append('<span id="heart_tip_big" style="position:absolute; z-index: 1000; background-color: pink; width: 62px;"><img src="' + cl_settings['images'] + 'loader.gif" alt="Loading" width="62" height="13" /></span>');
75
+ // find where to put left edge of info box (in case at right hand side of screen
76
+ //opera Netscape 6 Netscape 4x Mozilla
77
+ if (window.innerWidth || window.innerHeight){
78
+ docwidth = window.innerWidth;
79
+ docheight = window.innerHeight;
80
+ }
81
+ //IE Mozilla
82
+ if (document.body.clientWidth || document.body.clientHeight){
83
+ docwidth = document.body.clientWidth;
84
+ docheight = document.body.clientHeight;
85
+ }
86
+
87
+ var xpos = getAbsoluteLeft(this);
88
+ if(xpos > (docwidth - 350)){
89
+ xpos = xpos - 320;
90
+ }
91
+ $('#heart_tip_big').css({'left':xpos + "px", 'margin-top' : '-17px'});
92
+ var linkspan = $(this).parents(".cluv");
93
+ var link = $(linkspan).find("a:first").attr("href");
94
+ var url = cl_settings['api_url'] + "?type=info&url=" + link + '&version='+ cl_settings['cl_version'] + '&callback=?';
95
+ do_info(url);
96
+ }
97
+ function heart_small(){
98
+ $(this).find("#heart_tip_big").remove();
99
+ }
100
+
101
+
102
+ });
103
+
104
+ function getAbsoluteLeft(objectId) {
105
+ // Get an object left position from the upper left viewport corner
106
+ o = objectId;
107
+ oLeft = o.offsetLeft // Get left position from the parent object
108
+ while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
109
+ oParent = o.offsetParent // Get parent object reference
110
+ oLeft += oParent.offsetLeft // Add parent left position
111
+ o = oParent
112
+ }
113
+ return oLeft
114
+ }
115
+
116
+ function do_info(url){
117
+ $.getJSON(url,function(data){
118
+ $('#heart_tip_big').css("width","350px");
119
+ $('#heart_tip_big').addClass("finalbig");
120
+ var title = data.items[0].title;
121
+ $('#heart_tip_big img').remove();
122
+ $('#heart_tip_big').html(title);
123
+ });
124
+ }
125
+ // *** functions
126
+ // the dostuff function. Fires when comment text area gets focus
127
+ function cl_dostuff(){
128
+ // only fire if checkbox is checked
129
+ if($('#doluv').is(":checked")){
130
+ var check=$(cl_settings['urlObj']).val();
131
+ // and there is a url provided
132
+ if(!check) { return }
133
+ $('#mylastpost img').attr("src",cl_settings['images'] + "loader.gif");
134
+ var url=cl_settings['api_url'] + "?type=request&url="+check+"&version="+ cl_settings['cl_version'] +"&callback=?";
135
+ // do the ajax call
136
+ $.getJSON(url,function(data){
137
+ $('#showmore').show();
138
+ $('#lastposts').empty();
139
+ // get if is a member and other meta data
140
+ var ismember = data.meta[0].ismember;
141
+ cl_settings['request_id'] = data.meta[0].request_id;
142
+ cl_settings['alert_message'] = data.meta[0].alert_message;
143
+ // add the returned data to select box (or div)
144
+ $('#lastposts').append(cl_settings['select_text'] + '<br/>');
145
+ $.each(data.items, function(j,item){
146
+ //get image type for this item
147
+ var imageurl = '<img class="cl_type_icon" src="' + cl_settings['images'] + data.items[j]['type'] + '.gif"' + ' alt="' + data.items[j]['type'] + '" border=0 />';
148
+ // construct vars for clchoose function
149
+ var titlestr = data.items[j]['title'];
150
+ // replace single and double quotes with backslash versions (to prevent the onclick=".. from getting split)
151
+ titlestr = titlestr.replace(/\'/g,"\\\'");
152
+ titlestr = titlestr.replace(/\"/g,"\\\'");
153
+ $('#lastposts').append("<span onClick=\"clchoose('" + data.items[j]['type'] + "','" + data.items[j].url + "','" + titlestr + "'," + j + "," + data.meta[0].request_id + ");\" class=\"choosepost\">" + imageurl + data.items[j]['title'] + "</span>");
154
+ });
155
+ cl_settings['typeimage'] = '<img class="cl_type_icon" src="' + cl_settings['images'] + data.items[0]['type'] + '.gif"' + ' alt="' + data.items[0]['type'] + '" border=0 />';
156
+ $('#mylastpost').html(cl_settings['typeimage'] + ' <a href="' + data.items[0].url +'" title="' + data.items[0]['type'] + '"> ' + data.items[0]['title'] + '</a>').fadeIn(1000);
157
+ $('input[name="request_id"]').val(cl_settings['request_id']);
158
+ $('input[name="choice_id"]').val("0");
159
+ $('input[name="cl_type"]').val(data.items[0]['type']);
160
+ $('#cl_post').val('<a href="' + data.items[0].url + '">' + data.items[0]['title'] + '</a>');
161
+ });
162
+ // disable focus event
163
+ $("textarea[name='" + cl_settings['comment'] + "']").unbind();
164
+ }
165
+ }
166
+
167
+ })(jQuery);
168
+
169
+ // functions called with onclick (outside scope of above block)
170
+ function clchoose(ptype,purl,pstr,pid,preq){
171
+ (function($) {
172
+ if(purl == "0"){
173
+ return;
174
+ }
175
+ // set hidden fields in form to hold values for identifying this choice
176
+ $('input[name="choice_id"]').val(pid);
177
+ $('input[name="request_id"]').val(preq);
178
+ $('input[name="cl_type"]').val(ptype);
179
+ $('#mylastpost a').attr("href",purl).text(pstr);
180
+ $('input[name="cl_post"]').val('<a href="' + purl + '">' + pstr + '</a>');
181
+ $('#mylastpost img').attr({src: cl_settings['images'] + ptype + '.gif',alt: ptype});
182
+ if($('#luv').is(":checked")){
183
+ $('input[name="cl_post"]').val('<a href="' + purl + '">' + pstr + '</a>');
184
+ }
185
+ })(jQuery);
186
+ }
js/hoverIntent.js ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * hoverIntent is similar to jQuery's built-in "hover" function except that
3
+ * instead of firing the onMouseOver event immediately, hoverIntent checks
4
+ * to see if the user's mouse has slowed down (beneath the sensitivity
5
+ * threshold) before firing the onMouseOver event.
6
+ *
7
+ * hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
8
+ * <http://cherne.net/brian/resources/jquery.hoverIntent.html>
9
+ *
10
+ * hoverIntent is currently available for use in all personal or commercial
11
+ * projects under both MIT and GPL licenses. This means that you can choose
12
+ * the license that best suits your project, and use it accordingly.
13
+ *
14
+ * // basic usage (just like .hover) receives onMouseOver and onMouseOut functions
15
+ * $("ul li").hoverIntent( showNav , hideNav );
16
+ *
17
+ * // advanced usage receives configuration object only
18
+ * $("ul li").hoverIntent({
19
+ * sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
20
+ * interval: 100, // number = milliseconds of polling interval
21
+ * over: showNav, // function = onMouseOver callback (required)
22
+ * timeout: 0, // number = milliseconds delay before onMouseOut function call
23
+ * out: hideNav // function = onMouseOut callback (required)
24
+ * });
25
+ *
26
+ * @param f onMouseOver function || An object with configuration options
27
+ * @param g onMouseOut function || Nothing (use configuration options object)
28
+ * @author Brian Cherne <brian@cherne.net>
29
+ */
30
+ (function($) {
31
+ $.fn.hoverIntent = function(f,g) {
32
+ // default configuration options
33
+ var cfg = {
34
+ sensitivity: 7,
35
+ interval: 100,
36
+ timeout: 0
37
+ };
38
+ // override configuration options with user supplied object
39
+ cfg = $.extend(cfg, g ? { over: f, out: g } : f );
40
+
41
+ // instantiate variables
42
+ // cX, cY = current X and Y position of mouse, updated by mousemove event
43
+ // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
44
+ var cX, cY, pX, pY;
45
+
46
+ // A private function for getting mouse position
47
+ var track = function(ev) {
48
+ cX = ev.pageX;
49
+ cY = ev.pageY;
50
+ };
51
+
52
+ // A private function for comparing current and previous mouse position
53
+ var compare = function(ev,ob) {
54
+ ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
55
+ // compare mouse positions to see if they've crossed the threshold
56
+ if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
57
+ $(ob).unbind("mousemove",track);
58
+ // set hoverIntent state to true (so mouseOut can be called)
59
+ ob.hoverIntent_s = 1;
60
+ return cfg.over.apply(ob,[ev]);
61
+ } else {
62
+ // set previous coordinates for next time
63
+ pX = cX; pY = cY;
64
+ // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
65
+ ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
66
+ }
67
+ };
68
+
69
+ // A private function for delaying the mouseOut function
70
+ var delay = function(ev,ob) {
71
+ ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
72
+ ob.hoverIntent_s = 0;
73
+ return cfg.out.apply(ob,[ev]);
74
+ };
75
+
76
+ // workaround for Mozilla bug: not firing mouseout/mouseleave on absolute positioned elements over textareas and input type="text"
77
+ var handleHover = function(e) {
78
+ var t = this;
79
+
80
+ // next two lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
81
+ var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
82
+ while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
83
+ if ( p == this ) {
84
+ if ( $.browser.mozilla ) {
85
+ if ( e.type == "mouseout" ) {
86
+ t.mtout = setTimeout( function(){doHover(e,t);}, 30 );
87
+ } else {
88
+ if (t.mtout) { t.mtout = clearTimeout(t.mtout); }
89
+ }
90
+ }
91
+ return;
92
+ } else {
93
+ if (t.mtout) { t.mtout = clearTimeout(t.mtout); }
94
+ doHover(e,t);
95
+ }
96
+ };
97
+
98
+ // A private function for handling mouse 'hovering'
99
+ var doHover = function(e,ob) {
100
+
101
+ // copy objects to be passed into t (required for event object to be passed in IE)
102
+ var ev = jQuery.extend({},e);
103
+
104
+ // cancel hoverIntent timer if it exists
105
+ if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }
106
+
107
+ // else e.type == "onmouseover"
108
+ if (e.type == "mouseover") {
109
+ // set "previous" X and Y position based on initial entry point
110
+ pX = ev.pageX; pY = ev.pageY;
111
+ // update "current" X and Y position based on mousemove
112
+ $(ob).bind("mousemove",track);
113
+ // start polling interval (self-calling timeout) to compare mouse coordinates over time
114
+ if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}
115
+
116
+ // else e.type == "onmouseout"
117
+ } else {
118
+ // unbind expensive mousemove event
119
+ $(ob).unbind("mousemove",track);
120
+ // if hoverIntent state is true, then call the mouseOut function after the specified delay
121
+ if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
122
+ }
123
+ };
124
+
125
+ // bind the function to the two event listeners
126
+ return this.mouseover(handleHover).mouseout(handleHover);
127
+ };
128
+ })(jQuery);
lang/commentluv.mo ADDED
Binary file
lang/commentluv.po ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: CommentLuv\n"
4
+ "POT-Creation-Date: \n"
5
+ "PO-Revision-Date: \n"
6
+ "Last-Translator: Andy Bailey <andy@teamplaylotto.com>\n"
7
+ "Language-Team: \n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=utf-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Poedit-KeywordsList: __;_e\n"
12
+ "X-Poedit-Basepath: .\n"
13
+ "X-Poedit-SearchPath-0: ..\n"
14
+
lang/commentluv.pot ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: commentluv\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2009-05-30 09:54-0000\n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: Andy Bailey <andy@teamplaylotto.com>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-Language: English\n"
13
+ "X-Poedit-Country: UNITED KINGDOM\n"
14
+ "X-Poedit-KeywordsList: __;_e\n"
15
+ "X-Poedit-Basepath: .\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+
18
+ #: ../commentluv-manager.php:11
19
+ msgid ""
20
+ "This plugin takes the url from the comment form and tries to parse the feed of the site and display the last entry made. \n"
21
+ "\t\t\t\t\tIf you have any questions, comments or if you have a good idea that you would like to see in the next version of CommentLuv, please visit FiddyP Blog or support forum and let me know."
22
+ msgstr ""
23
+
24
+ #: ../commentluv-manager.php:13
25
+ msgid "Display Options"
26
+ msgstr ""
27
+
28
+ #: ../commentluv-manager.php:14
29
+ msgid "Enter the text you want displayed in the comment"
30
+ msgstr ""
31
+
32
+ #: ../commentluv-manager.php:17
33
+ msgid "Text displayed in the select box"
34
+ msgstr ""
35
+
36
+ #: ../commentluv-manager.php:21
37
+ msgid "CommentLuv on by default?"
38
+ msgstr ""
39
+
40
+ #: ../commentluv-manager.php:24
41
+ msgid "Show heart on links?"
42
+ msgstr ""
43
+
44
+ #: ../commentluv-manager.php:28
45
+ msgid "Use template insert to show badge and checkbox?"
46
+ msgstr ""
47
+
48
+ #: ../commentluv-manager.php:30
49
+ msgid "Display Badge"
50
+ msgstr ""
51
+
52
+ #: ../commentluv-manager.php:31
53
+ msgid "Many thanks to <a href=\"http://byteful.com\">Byteful Traveller</a> for creating these images."
54
+ msgstr ""
55
+
56
+ #: ../commentluv-manager.php:34
57
+ msgid "Choose badge to display"
58
+ msgstr ""
59
+
60
+ #: ../commentluv-manager.php:40
61
+ msgid "Show nothing"
62
+ msgstr ""
63
+
64
+ #: ../commentluv-manager.php:43
65
+ msgid "Show text"
66
+ msgstr ""
67
+
68
+ #: ../commentluv-manager.php:43
69
+ msgid "Prepend html before badge or text (optional)"
70
+ msgstr ""
71
+
72
+ #: ../commentluv-manager.php:45
73
+ msgid "CommentLuv Member Area"
74
+ msgstr ""
75
+
76
+ #: ../commentluv-manager.php:46
77
+ msgid "If you register your site for free at <a href=\"http://comluv.com\">ComLuv.com</a> you will be able to open up lots of features that are for members only like link tracking so you can see which of the comments you make on CommentLuv blogs are getting the last blog post clicked and the ability to send back more than just blog posts. You can even create your own WP2.7 blog there with commentluv pre-installed!."
78
+ msgstr ""
79
+
80
+ #: ../commentluv-manager.php:48
81
+ msgid "Technical Settings"
82
+ msgstr ""
83
+
84
+ #: ../commentluv-manager.php:49
85
+ msgid "In most cases you shouldn't need to change these settings unless you have a customized comment form"
86
+ msgstr ""
87
+
88
+ #: ../commentluv-manager.php:53
89
+ msgid "Authors Name field name"
90
+ msgstr ""
91
+
92
+ #: ../commentluv-manager.php:57
93
+ msgid "Email field name"
94
+ msgstr ""
95
+
96
+ #: ../commentluv-manager.php:61
97
+ msgid "Authors URL field name"
98
+ msgstr ""
99
+
100
+ #: ../commentluv-manager.php:65
101
+ msgid "Comment Text Area name"
102
+ msgstr ""
103
+
104
+ #: ../commentluv-manager.php:73
105
+ msgid "Reset to Default Settings"
106
+ msgstr ""
107
+
108
+ #: ../commentluv-manager.php:78
109
+ msgid "Are you sure you want to reset your settings? Press OK to continue"
110
+ msgstr ""
111
+
112
+ #: ../commentluv.php:50
113
+ msgid "CommentLuv requires Wordpress 2.6.5 or newer."
114
+ msgstr ""
115
+
116
+ #: ../commentluv.php:52
117
+ msgid "Please Update!"
118
+ msgstr ""
119
+
120
+ #: ../commentluv.php:86
121
+ msgid "Settings"
122
+ msgstr ""
123
+
124
+ #: ../commentluv.php:205
125
+ msgid "There were errors with your chosen settings"
126
+ msgstr ""
127
+
readme.txt ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === CommentLuv ===
2
+ Contributors: teamplaylotto
3
+ Donate link:http://comluv.com/about/donate
4
+ Tags: commentluv, comments, last blog post, linkluv
5
+ Requires at least: 2.6.5
6
+ Tested up to: 2.7.1
7
+ Stable tag: 2.7
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
+
11
+ == Description ==
12
+
13
+ This plugin will visit the site of the comment author while they type their comment and retrieve a selection of their last blog posts, tweets or digg submissions which they can choose one from to include at the bottom of their comment when they click submit.
14
+
15
+ It has been found to increase comments and the community spirit for the thousands of blogs that have installed it. With a simple install you will immediately start to find new and interesting blog posts, tweets and diggs from your own blog and community.
16
+
17
+ The plugin requires WP or WPMU version of at least 2.7 and will work with administrators and logged on users provided they have their homepage url set in their profile page in the dashboard of the site.
18
+
19
+ With a full support site where you can unlock great new features, start your own WP2.7 blog with CommentLuv already installed and set up, view your stats for comments made and received and much more.
20
+
21
+ You can visit http://comluv.com to find out more about this plugin.
22
+
23
+
24
+
25
+ == Installation ==
26
+
27
+ Wordpress : Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation and then activate the Plugin from Plugins page.
28
+
29
+ WordpressMu : Same as above
30
+ == Frequently Asked Questions ==
31
+
32
+ =Does this plugin add any database tables?=
33
+
34
+ No. The link and a small bit of associated data is appended to the comment content at the time of submission
35
+
36
+ =Will this plugin work with Disqus/Intense Debate/js-kit?=
37
+
38
+ There will be a separate version of CommentLuv for external comment systems due to the regular updates they go through
39
+ == Screenshots ==
40
+ 1. settings page
41
+
42
+ 2. in use
43
+ This plugin inserts fields to the comment form at run time. If you find there is no badge shown on the comment form after you first install it, please check your comments.php file for the command &lt;?php do\_action('comment\_form', $post->ID); ?&gt; before the &lt;/form> tag
44
+
45
+ For logged on users and administrators, be sure to check your profile and make sure there is a url entered.
screenshot-1.jpg ADDED
Binary file
screenshot-2.jpg ADDED
Binary file
style/cl_style.css ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #mylastpost {
2
+
3
+ }
4
+ #doluv{
5
+
6
+ }
7
+ #commentluv {
8
+ clear: both;
9
+ }
10
+ #commentluv img{
11
+ border: 0 !important;
12
+ padding: 0 !important;
13
+ }
14
+ .cluv {
15
+ border:1px solid #fff;
16
+ padding: 5px;
17
+ display: block
18
+ }
19
+ #lastposts {
20
+ width: 500px;
21
+ padding-left: 5px;
22
+ padding-bottom: 5px;
23
+ background-color: #fee;
24
+ font-size: 13px;
25
+ border: 1px solid #ddd;
26
+ color: #000;
27
+ }
28
+
29
+ .choosepost {
30
+ background-color: #fff;
31
+ line-height: 1.4em;
32
+ display: block;
33
+ width: 495px;
34
+ border-bottom: 1px dashed #bbb;
35
+ cursor: pointer;
36
+ }
37
+
38
+ .cl_type_icon {
39
+ margin-right: 3px;
40
+ border: 0 !important;
41
+ padding: 0 !important;
42
+ }
43
+
44
+ .heart_tip {
45
+ margin-left: 5px;
46
+ display: inline;
47
+ margin-bottom: 0px;
48
+ margin-right: 0px;
49
+ padding: 0px !important;
50
+ background-color: transparent;
51
+ border: 0 !important;
52
+ }
53
+
54
+ .finalbig{
55
+ padding: 3px;
56
+ -moz-border-radius-topleft: 8px;
57
+ -khtml-border-top-left-radius: 8px;
58
+ -webkit-border-top-left-radius: 8px;
59
+ border-top-left-radius: 8px;
60
+ -moz-border-radius-topright: 8px;
61
+ -khtml-border-top-right-radius: 8px;
62
+ -webkit-border-top-right-radius: 8px;
63
+ border-top-right-radius: 8px;
64
+ -moz-border-radius-bottomleft: 8px;
65
+ -khtml-border-bottom-left-radius: 8px;
66
+ -webkit-border-bottom-left-radius: 8px;
67
+ border-bottom-left-radius: 8px;
68
+ -moz-border-radius-bottomright: 8px;
69
+ -khtml-border-bottom-right-radius: 8px;
70
+ -webkit-border-bottom-right-radius: 8px;
71
+ border-bottom-right-radius: 8px;
72
+ font-size: 1em;
73
+ color: #000;
74
+ }
75
+ .finalbig img {
76
+ margin: 3px;
77
+ }
78
+
twitter_48.png DELETED
Binary file
wp-twitip-id-manager.php DELETED
@@ -1,118 +0,0 @@
1
- <?php
2
- // version 1.0
3
- if ( ! defined( 'WP_PLUGIN_URL' ) )
4
- define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
5
- $addtwitterfielddirectory = WP_PLUGIN_URL . '/' . dirname( plugin_basename(__FILE__) );
6
-
7
- // function for dealing with a checkbox in settings. Checks if it was on in the options and sends back checked=true if it is.
8
- function atf_checkCheckbox( $theFieldname ){
9
- if( get_option( $theFieldname ) == 'on'){
10
- echo 'checked="true"';
11
- }
12
- return;
13
- }
14
-
15
- // update settings from posted variables
16
- if ($_POST['submit']=='update'){
17
- update_option('atf_swap',$_POST['atf_swap']);
18
- update_option('atf_afterID',$_POST['atf_afterID']);
19
- update_option('atf_prehtml',atf_slashit($_POST['atf_prehtml']));
20
- update_option('atf_psthtml',atf_slashit($_POST['atf_psthtml']));
21
- update_option('atf_field_class',$_POST['atf_field_class']);
22
- update_option('atf_image_url',$_POST['atf_image_url']);
23
- update_option('atf_anchor_text',$_POST['atf_anchor_text']);
24
- update_option('atf_nolabels',$_POST['atf_nolabels']);
25
- update_option('atf_nojava',$_POST['atf_nojava']);
26
- }
27
- ?>
28
- <style type="text/css">
29
- <!--
30
- #addtwitterfield fieldset {
31
- margin: 0;
32
- padding:0;
33
- border: none;
34
- }
35
- #addtwitterfield form p {
36
- background: #eaf3fa;
37
- padding: 10px 5px;
38
- margin: 4px 0;
39
- border: 1px solid #eee;
40
- }
41
- #addtwitterfield form .error p {
42
- background: none;
43
- border: none;
44
- }
45
- .floatright {
46
- float: right;
47
- }
48
- -->
49
- </style>
50
- <div class="wrap" id="addtwitterfield">
51
- <h3>Usage:</h3>
52
- <p>Put this in your comments.php file where you want to output the link<br/>
53
- "image" : outputs image pointed to by image url field (uses anchor text as title attribute)<br/>
54
- "text" : outputs text link using anchor text<br/>
55
- "return": returns twitter id as variable to be used in php<br/>
56
- "auto" : returns Twitter: @commentluv (linked username in a span with class="twitter_id")</p>
57
- example:
58
- <code>&lt;?php if(function_exists(wp_twitip_id_show)) {
59
- wp_twitip_id_show("auto");
60
- }?&gt;</code>
61
- <p>returns:<br/> Twitter: <a href="http://twitter.com/commentluv">@CommentLuv</a></p>
62
- For styling use
63
- .twitter_id {
64
- font-size: 10px;
65
- }
66
-
67
- <h1>WP-Twitip-ID Options</h1>
68
- Version: <?php echo get_option($atf_db_version);?>
69
- <form method="post">
70
- <div>
71
- <fieldset>
72
-
73
- <p>
74
- <label for="atf_afterID">Put field after object ID</label><br/>
75
- <input type="text" name="atf_afterID" id="atf_afterID" size="20" maxlength="30" value="<?php echo get_option('atf_afterID') ?>" />
76
- <br/><small>Enter the value of the ID attribute of the object you want the extra field to appear after.<br/>Default: url</small>
77
- </p><p>
78
- <input type="checkbox" name="atf_swap" id="atf_swap" <?php atf_checkCheckbox('atf_swap')?> />
79
- <label for="atf_swap">Labels are before fields?</label>
80
- <br/><small>If your form uses the &lt;label tag before the &lt;input tag select this<br/>Default: off</small>
81
- <br/><input type="checkbox" name="atf_nolabels" id="atf_nolabels" <?php atf_checkCheckbox('atf_nolabels')?> />
82
- <label for="atf_nolabels">No Labels</label>
83
- <br/><small>If your form doesn't use labels check here<br/>Default: off</small>
84
- <br/><input type="checkbox" name="atf_nojava" id="atf_nojava" <?php atf_checkCheckbox('atf_nojava')?> />
85
- <label for="atf_nojava">Do not use javascript to add the field</label>
86
- <br/><small>If you have edited your comments.php file to manually add a field with name="atf_twitter_id" then select this box<br/>Default: off</small>
87
- </p>
88
- <p>
89
- <label for="atf_prehtml">HTML before Field</label><br />
90
- <textarea name="atf_prehtml" id="atf_prehtml" cols="40" rows="5"><?php echo atf_deslashit(get_option('atf_prehtml')); ?></textarea>
91
- <br/><small>The HTML you want to put before the extra field (if you have checked the box above then you should put your label html here)<br/>Default: &lt;br/&gt;</small>
92
- </p>
93
- <p>
94
- <label for="atf_psthtml">HTML after Field</label><br />
95
- <textarea name="atf_psthtml" id="atf_psthtml" cols="40" rows="5"><?php echo atf_deslashit(get_option('atf_psthtml')); ?></textarea>
96
- <br/><small>The HTML you want to put after the extra field (if you have checked the box above then you should not put the label html here)<br/>Default: &lt;br/&gt;&lt;label for="atf_twitter_id"&gt;Twitter ID&lt;/label&gt; </small>
97
- </p>
98
- <p>
99
- <label for="atf_field_class">Field Class</label><br/>
100
- <input type="text" name="atf_field_class" id="atf_field_class" size="20" maxlength="35" value="<?php echo get_option('atf_field_class') ?>" />
101
- <br/><small>You can enter the class of your current fields here to match your theme<br/>Default: textarea</small>
102
- </p>
103
- <p>
104
- <label for="atf_image_url">Twitter Image URI</label><br/>
105
- <input type="text" name="atf_image_url" id="atf_image_url" size="40" maxlength="150" value="<?php echo get_option('atf_image_url') ?>" />
106
- <br/><small>URL to the image you want displayed when using "image" as output<br/>Default: <?php echo WP_PLUGIN_URL.'/'.dirname( plugin_basename(__FILE__)).'/twitter_48.png';?></small>
107
- </p>
108
- <p>
109
- <label for="atf_anchor_text">Link anchor text</label><br/>
110
- <input type="text" name="atf_anchor_text" id="atf_anchor_text" size="40" maxlength="150" value="<?php echo get_option('atf_anchor_text') ?>" />
111
- <br/><small>Text to use as link when using "text" as output (also is used for the title attribute of the image if using "image")<br/>Default: null</small>
112
- </p>
113
- <input type="submit" name="submit" value="update" />
114
- </fieldset>
115
-
116
- </div>
117
- </form>
118
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wp-twitip-id.php DELETED
@@ -1,230 +0,0 @@
1
- <?php
2
- /*
3
- Plugin Name: WP Twitip ID
4
- Plugin URI: http://www.fiddyp.co.uk/wp-twitip-id-plugin-add-a-twitter-field-to-your-comment-form-easily/
5
- Description: Adds another field to the comment form to allow the user to include their twitter id. Inspired by @problogger post http://tinyurl.com/6gns3f and kicked up the bum by @styletime.
6
- Version: 1.0
7
- Author: Andy Bailey
8
- Author URI: http://www.fiddyp.co.uk
9
-
10
- Copyright (C) <2009> <Andy Bailey>
11
-
12
- This program is free software: you can redistribute it and/or modify
13
- it under the terms of the GNU General Public License as published by
14
- the Free Software Foundation, either version 3 of the License, or
15
- (at your option) any later version.
16
-
17
- This program is distributed in the hope that it will be useful,
18
- but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- GNU General Public License for more details.
21
-
22
- You should have received a copy of the GNU General Public License
23
- along with this program. If not, see <http://www.gnu.org/licenses/>.
24
-
25
- v0.1 21 Nov 08 - @styletime DM received, plugin idea accepted. WTH do I do now? :-)
26
- v0.2 22 Nov 08 - changed paramters of template call, use image, text, user to output linked image or text using anchor or output @username only or return as variable type of string
27
- v0.3 - added image for default usage (in case people don't know to go to the settings page)
28
- v0.4 23 Nov 08 - change .js.php file to not add slashes. Added nolabel checkbox for themes without a label set for the fields
29
- v0.5 updated way js file calls wp-load.php by sending a GET value with path from inside plugin
30
- v0.6 24 nov 08 - added rel="nofollow" to links and used safer way of including javascript.
31
- v0.7 27 nov 08 - update post meta (thanks @saphod), append atfemail to email key in post meta for easy removing in the future (database clean)
32
- v0.8 28 nov 08 - added nojava option for people adding field manually to comments.php
33
- v0.9 29 nov 08 - slight change to js for cookie field (don't comma the form obj) uses blur now instead of change. Add tab index bit
34
- v1.0 11 feb 09 - add a new table for storing twitter id's for email address. only 1 comment needed for storing the id and it shows on all future comments
35
- and added the atf_slashit and atf_deslashit for storing html in wp_options properly
36
- and added "auto" as an output for displaying Twitter: @commentluv
37
- a BIG THANKS to @clearskynet for helping me with the table creation!
38
- */
39
-
40
- function atf_install() {
41
- global $wpdb;
42
- $table_name = $wpdb->prefix . "wptwitipid";
43
- if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
44
- $sql = "CREATE TABLE " . $table_name . " (
45
- id mediumint(9) NOT NULL AUTO_INCREMENT,
46
- email varchar(120) NOT NULL,
47
- twitid varchar(120) NOT NULL,
48
- PRIMARY KEY (id),
49
- KEY (email)
50
- );";
51
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
52
- dbDelta($sql);
53
- }
54
- }
55
- function atfplugin_action($links, $file) {
56
- // adds the link to the settings page in the plugin list page
57
- if ($file == plugin_basename(dirname(__FILE__).'/wp-twitip-id.php'))
58
- $links[] = "<a href='options-general.php?page=wp-twitip-id/wp-twitip-id.php'>" . __('Settings', 'WP-Twitip-ID') . "</a>";
59
- return $links;
60
- }
61
- function addtwitterfieldadminpage() {
62
- // Add the administrative settings to the "Settings" menu by calling manage_page function
63
- if ( function_exists( 'add_submenu_page' ) ) {
64
- add_options_page( 'WP Twitip ID', 'WP Twitip ID', 8, __FILE__, 'addtwitterfield_manage_page' );
65
- }
66
- }
67
- function addtwitterfield_manage_page() {
68
- // Include the Manager page from file in plugin directory
69
- include(dirname(__FILE__).'/wp-twitip-id-manager.php' );
70
- }
71
- // add slashes to html if magic quotes is not on
72
- function atf_slashit($stringvar){
73
- if (!get_magic_quotes_gpc()){
74
- $stringvar = addslashes($stringvar);
75
- }
76
- return $stringvar;
77
- }
78
- // remove slashes if magic quotes is on
79
- function atf_deslashit($stringvar){
80
- if (1 == get_magic_quotes_gpc()){
81
- $stringvar = stripslashes($stringvar);
82
- }
83
- return $stringvar;
84
- }
85
- function addtwitterfieldscript(){
86
- // add the script reference to the header
87
- // Pre-2.6 compatibility
88
- if ( ! defined( 'WP_CONTENT_URL' ) )
89
- define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
90
- if ( ! defined( 'WP_CONTENT_DIR' ) )
91
- define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
92
- if ( ! defined( 'WP_PLUGIN_URL' ) )
93
- define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
94
- if ( ! defined( 'WP_PLUGIN_DIR' ) )
95
- define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
96
- global $atf_head_done;
97
- if(!$atf_head_done){
98
- echo '<script type="text/javascript" src="'.WP_PLUGIN_URL.'/'.
99
- dirname( plugin_basename(__FILE__)).'/js/addtwitterfield.js"></script>';
100
- $afterID=str_replace("#","",get_option('atf_afterID'));
101
- $prehtml=get_option('atf_prehtml');
102
- $psthtml=get_option('atf_psthtml');
103
- $field_class=get_option('atf_field_class');
104
- $hasnolabel=get_option('atf_nolabels');
105
- $swaplabel=get_option('atf_swap');
106
- $atf_nojava=get_option('atf_nojava');
107
- echo "<!-- added by wp-twitip-id by Andy Bailey -->\n";
108
- echo "<script type=\"text/javascript\">";
109
- echo "addtwitterfield('$afterID',\"$prehtml\",\"$psthtml\",'$field_class','$hasnolabel','$swaplabel','$atf_nojava');</script>";
110
- $atf_head_done=1;
111
- }
112
- }
113
- // plugin activate
114
- function addtwitterfield_activation(){
115
- add_option('atf_afterID','url');
116
- add_option('atf_prehtml','<br/>');
117
- add_option('atf_psthtml',atf_slashit('<label for="atf_twitter_id">Twitter ID</label><br/>'));
118
- add_option('atf_field_class','textarea');
119
- add_option('atf_image_url',WP_PLUGIN_URL.'/'.dirname( plugin_basename(__FILE__)).'/twitter_48.png');
120
- add_option('atf_nolabels','off');
121
- add_option('atf_swap','off');
122
- add_option('atf_nojava','off');
123
- add_option("atf_db_version", "1.0");
124
- atf_install();
125
- }
126
- // save the twitter id with the author email in the post meta
127
- function addtwitterfieldmeta($comment_data){
128
- // get twitter id from post variables
129
- $twitter=$_POST['atf_twitter_id'];
130
- // access db
131
- global $wpdb;
132
- $table_name = $wpdb->prefix . "wptwitipid";
133
- if($twitter){
134
- // chop off any @ symbol or http twitter address
135
- $find=array("@","http://twitter.com/");
136
- $replace=array("","");
137
- $twitterid = str_replace($find,$replace,$twitter);
138
-
139
- // store twitter id wptiwitpid
140
- $exists = $wpdb->get_var("SELECT twitid FROM $table_name WHERE email = '".$comment_data['comment_author_email']."'");
141
- if(!$exists){
142
- // none yet, insert
143
- $wpdb->query("INSERT INTO $table_name (email, twitid) VALUES ('".mysql_real_escape_string($comment_data['comment_author_email'])."','".mysql_real_escape_string($twitterid)."');");
144
- return $comment_data;
145
- }
146
- if ($twitterid != $exists){
147
- //exists but is different so update to new value
148
- $query="UPDATE $table_name SET twitid = '".mysql_real_escape_string($twitterid)."' WHERE email = '".mysql_real_escape_string($comment_data['comment_author_email'])."'";
149
- $wpdb->query($query);
150
- }
151
-
152
- }
153
- return $comment_data;
154
- }
155
-
156
- function wp_twitip_id_show ($type){
157
- // display the twitter id associated with this comment
158
- // get post id
159
- global $wpdb;
160
- $table_name = $wpdb->prefix . "wptwitipid";
161
- // get comment
162
- global $comment;
163
- $email = $comment->comment_author_email;
164
- // get data from settings
165
- $image_url = get_option('atf_image_url');
166
- $anchor_text = get_option('atf_anchor_text');
167
- // construct url
168
- $url="http://twitter.com/";
169
- // output if twitter id asociated with users email on this post
170
- if($twitter = $wpdb->get_var("SELECT twitid FROM $table_name WHERE email ='$email'")){
171
- // twitter id exists for this email
172
- if($type == "image" && $image_url){
173
- echo '<span class="twitter_id"><a rel="nofollow" target="_blank" href="',$url,$twitter,'"><img src="',$image_url,'" alt="twitter" title="',$anchor_text,'"/></a></span>';
174
- } elseif(!$image_url){
175
- $type="text";
176
- }
177
- if($type == "text"){
178
- if(!$anchor_text) {
179
- $anchor_text="Click to follow me on twitter";
180
- }
181
- echo '<span class="twitter_id"><a rel="nofollow" target="_blank" href="',$url,$twitter,'">',$anchor_text,'</a></span>';
182
- }
183
- if($type == "user"){
184
- echo "@",$twitter;
185
- }
186
- if($type == "return"){
187
- return $twitter;
188
- }
189
- if($type == "auto") {
190
- echo '<span class="twitter_id">Twitter: <a rel="nofollow" target="_blank" href="',$url,$twitter,'">@',$twitter,'</a></span>';
191
- }
192
- }
193
-
194
- return ;
195
- }
196
- // it all starts here you know.
197
- $atf_head_done=0;
198
-
199
- // filters and actions
200
- add_filter('plugin_action_links', 'atfplugin_action', -10, 2);
201
- add_action( 'admin_menu', 'addtwitterfieldadminpage' );
202
- add_action('wp_head','addtwitterfieldscript');
203
- add_action('preprocess_comment','addtwitterfieldmeta',0);
204
-
205
- register_activation_hook(__FILE__, 'addtwitterfield_activation');
206
-
207
-
208
- if (!function_exists('wp_prototype_before_jquery')) {
209
- function wp_prototype_before_jquery( $js_array ) {
210
- if ( false === $jquery = array_search( 'jquery', $js_array ) )
211
- return $js_array;
212
-
213
- if ( false === $prototype = array_search( 'prototype', $js_array ) )
214
- return $js_array;
215
-
216
- if ( $prototype < $jquery )
217
- return $js_array;
218
-
219
- unset($js_array[$prototype]);
220
-
221
- array_splice( $js_array, $jquery, 0, 'prototype' );
222
-
223
- return $js_array;
224
- }
225
-
226
- add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
227
- }
228
-
229
- wp_enqueue_script('jquery');
230
- ?>