CommentLuv - Version 2.93.1

Version Description

  • updated : prevent notice in admin for $authurl , check it is in $comment before trying to use it
Download this release

Release Info

Developer commentluv
Plugin Icon 128x128 CommentLuv
Version 2.93.1
Comparing to
See all releases

Code changes from version 2.93 to 2.93.1

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