I Recommend This - Version 1.4.2

Version Description

Download this release

Release Info

Developer hchouhan
Plugin Icon 128x128 I Recommend This
Version 1.4.2
Comparing to
See all releases

Code changes from version 1.4.1 to 1.4.2

Files changed (2) hide show
  1. i-recommend-this.php +1 -357
  2. readme.txt +1 -1
i-recommend-this.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: I Recommend This
4
  Plugin URI: http://www.harishchouhan.com/personal-projects/i-recommend-this/
5
  Description: This plugin allows your visitors to simply recommend or like your posts instead of commment it.
6
- Version: 1.4.1
7
  Author: Harish Chouhan
8
  Author URI: http://www.harishchouhan.com
9
 
@@ -363,360 +363,4 @@ function addHeaderLinks() {
363
 
364
  add_action('init', enqueueScripts);
365
  add_action('wp_head', addHeaderLinks);
366
- ?><?php
367
- /*
368
- Plugin Name: I Recommend This
369
- Plugin URI: http://www.harishchouhan.com/personal-projects/i-recommend-this/
370
- Description: This plugin allows your visitors to simply recommend or like your posts instead of commment it.
371
- Version: 1.3.1
372
- Author: Harish Chouhan
373
- Author URI: http://www.harishchouhan.com
374
-
375
- Copyright 2012 Harish Chouhan (email : me@harishchouhan.com)
376
-
377
- This program is free software; you can redistribute it and/or modify
378
- it under the terms of the GNU General Public License as published by
379
- the Free Software Foundation; either version 2 of the License, or
380
- (at your option) any later version.
381
-
382
- This program is distributed in the hope that it will be useful,
383
- but WITHOUT ANY WARRANTY; without even the implied warranty of
384
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
385
- GNU General Public License for more details.
386
- */
387
-
388
-
389
-
390
- #### INSTALL PROCESS ####
391
- $irt_dbVersion = "1.0";
392
-
393
- function setOptionsIRT() {
394
- global $wpdb;
395
- global $irt_dbVersion;
396
-
397
- $table_name = $wpdb->prefix . "irecommendthis_votes";
398
- if($wpdb->get_var("show tables recommend '$table_name'") != $table_name) {
399
- $sql = "CREATE TABLE " . $table_name . " (
400
- id MEDIUMINT(9) NOT NULL AUTO_INCREMENT,
401
- time TIMESTAMP NOT NULL,
402
- post_id BIGINT(20) NOT NULL,
403
- ip VARCHAR(15) NOT NULL,
404
- UNIQUE KEY id (id)
405
- );";
406
-
407
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
408
- dbDelta($sql);
409
-
410
- add_option("irt_dbVersion", $irt_dbVersion);
411
- }
412
-
413
- add_option('irt_jquery', '1', '', 'yes');
414
- add_option('irt_onPage', '1', '', 'yes');
415
- add_option('irt_textOrNotext', 'notext', '', 'yes');
416
- add_option('irt_text', 'I recommend This', '', 'yes');
417
- add_option('irt_textOnclick', 'recommends', '', 'yes');
418
- }
419
-
420
- register_activation_hook(__FILE__, 'setOptionsIRT');
421
-
422
- function unsetOptionsIRT() {
423
- global $wpdb;
424
- $wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."irecommendthis_votes");
425
-
426
- delete_option('irt_jquery');
427
- delete_option('irt_onPage');
428
- delete_option('irt_textOrNotext');
429
- delete_option('irt_text');
430
- delete_option('irt_textOnclick');
431
- delete_option('most_recommended_posts');
432
- delete_option('irt_dbVersion');
433
- }
434
-
435
- register_uninstall_hook(__FILE__, 'unsetOptionsIRT');
436
- ####
437
-
438
-
439
- #### ADMIN OPTIONS ####
440
- function IRecommendThisAdminMenu() {
441
- add_options_page('I Recommend This', 'I Recommend This', '10', 'IRecommendThisAdminMenu', 'IRecommendThisAdminContent');
442
- }
443
- add_action('admin_menu', 'IRecommendThisAdminMenu');
444
-
445
- function IRecommendThisAdminRegisterSettings() { // whitelist options
446
- register_setting( 'irt_options', 'irt_jquery' );
447
- register_setting( 'irt_options', 'irt_onPage' );
448
- register_setting( 'irt_options', 'irt_textOrNotext' );
449
- register_setting( 'irt_options', 'irt_text' );
450
- register_setting( 'irt_options', 'irt_textOnclick' );
451
- }
452
- add_action('admin_init', 'IRecommendThisAdminRegisterSettings');
453
-
454
- function IRecommendThisAdminContent() {
455
  ?>
456
- <div class="wrap">
457
- <h2>"I Recommend This" Options</h2>
458
- <br class="clear" />
459
-
460
- <div id="poststuff" class="ui-sortable meta-box-sortables">
461
- <div id="irecommendthisoptions" class="postbox">
462
- <h3><?php _e('Configuration'); ?></h3>
463
- <div class="inside">
464
- <form method="post" action="options.php">
465
- <?php settings_fields('irt_options'); ?>
466
- <table class="form-table">
467
- <tr valign="top">
468
- <th scope="row"><label for="irt_jquery"><?php _e('jQuery framework', 'i-recommend-this'); ?></label></th>
469
- <td>
470
- <select name="irt_jquery" id="irt_jquery">
471
- <?php echo get_option('irt_jquery') == '1' ? '<option value="1" selected="selected">'.__('Enabled', 'i-recommend-this').'</option><option value="0">'.__('Disabled', 'i-recommend-this').'</option>' : '<option value="1">'.__('Enabled', 'i-recommend-this').'</option><option value="0" selected="selected">'.__('Disabled', 'i-recommend-this').'</option>'; ?>
472
- </select>
473
- <span class="description"><?php _e('Disable it if you already have the jQuery framework enabled in your theme.', 'i-recommend-this'); ?></span>
474
- </td>
475
- </tr>
476
- <tr valign="top">
477
- <th scope="row"><legend><?php _e('No Text or Text?', 'i-recommend-this'); ?></legend></th>
478
- <td>
479
- <label for="irt_textOrNotext" style="padding:3px 20px 0 0; margin-right:20px;">
480
- <?php echo get_option('irt_textOrNotext') == 'notext' ? '<input type="radio" name="irt_textOrNotext" id="irt_textOrNotext" value="image" checked="checked">' : '<input type="radio" name="irt_textOrNotext" id="irt_textOrNotext" value="notext">'; ?> No Text
481
- </label>
482
- <label for="irt_text">
483
- <?php echo get_option('irt_textOrNotext') == 'text' ? '<input type="radio" name="irt_textOrNotext" id="irt_textOrNotext" value="text" checked="checked">' : '<input type="radio" name="irt_textOrNotext" id="irt_textOrNotext" value="text">'; ?>
484
- <input type="text" name="irt_text" id="irt_text" value="<?php echo get_option('irt_text'); ?>" />
485
- </label>
486
- </td>
487
- </tr>
488
- <tr valign="top">
489
- <th scope="row"><legend><?php _e('Automatic display', 'i-recommend-this'); ?></legend></th>
490
- <td>
491
- <label for="irt_onPage">
492
- <?php echo get_option('irt_onPage') == '1' ? '<input type="checkbox" name="irt_onPage" id="ilt_onPage" value="1" checked="checked">' : '<input type="checkbox" name="irt_onPage" id="irt_onPage" value="1">'; ?>
493
- <?php _e('<strong>On all posts</strong> (home, archives, search) at the bottom of the post', 'i-recommend-this'); ?>
494
- </label>
495
- <p class="description"><?php _e('If you disable this option, you have to put manually the code', 'i-recommend-this'); ?><code>&lt;?php if(function_exists(getIRecommendThis)) getIRecommendThis('get'); ?&gt;</code> <?php _e('wherever you want in your template.', 'i-recommend-this'); ?></p>
496
- </td>
497
- </tr>
498
- <tr valign="top">
499
- <th scope="row"><input class="button-primary" type="submit" name="Save" value="<?php _e('Save Options', 'i-recommend-this'); ?>" /></th>
500
- <td></td>
501
- </tr>
502
- </table>
503
- </form>
504
- </div>
505
- </div>
506
- </div>
507
- </div>
508
- <?php
509
- }
510
- ####
511
-
512
-
513
- #### WIDGET ####
514
- function most_recommended_posts($numberOf, $before, $after, $show_count, $post_type="post", $raw=false) {
515
- global $wpdb;
516
-
517
- $request = "SELECT * FROM $wpdb->posts, $wpdb->postmeta";
518
- $request .= " WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id";
519
- $request .= " AND post_status='publish' AND post_type='$post_type' AND meta_key='_recommended'";
520
- $request .= " ORDER BY $wpdb->postmeta.meta_value+0 DESC LIMIT $numberOf";
521
- $posts = $wpdb->get_results($request);
522
-
523
- if ($raw):
524
- return $posts;
525
- else:
526
- foreach ($posts as $item) {
527
- $post_title = stripslashes($item->post_title);
528
- $permalink = get_permalink($item->ID);
529
- $post_count = $item->meta_value;
530
- echo $before.'<a href="' . $permalink . '" title="' . $post_title.'" rel="nofollow">' . $post_title . '</a>';
531
- echo $show_count == '1' ? ' ('.$post_count.')' : '';
532
- echo $after;
533
- }
534
- endif;
535
- }
536
-
537
- /**
538
- * Mini counter widget
539
- */
540
- function most_recommended_recommend_widget(){
541
- global $wpdb;
542
- $post_ID = get_the_ID();
543
- $ip = $_SERVER['REMOTE_ADDR'];
544
-
545
- $liked = get_post_meta($post_ID, '_recommended', true) != '' ? get_post_meta($post_ID, '_recommended', true) : '0';
546
- $voteStatusByIp = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."irecommendthis_votes WHERE post_id = '$post_ID' AND ip = '$ip'");
547
-
548
-
549
- $return='<div class="irt_counter_widget">';
550
- if (!isset($_COOKIE['recommended-'.$post_ID]) && $voteStatusByIp == 0) {
551
- $return.='<p class="irt_counter_widget_btn"><a onclick="recommendThis('.$post_ID.');">Vote!</a></p>';
552
- }
553
- else {
554
- $return.='<p class="irt_counter_widget_btn recommended">Voted</p>';
555
- }
556
- $return.= '<p class="irt_counter_widget_counter" id="'.$post_ID.'">'.$recommended.' lights</p>';
557
- $return.= '</div>';
558
- echo $return;
559
- }
560
-
561
- /**
562
- * SIDEBAR WIDGET
563
- */
564
- function add_widget_most_recommended_posts() {
565
- function widget_most_recommended_posts($args) {
566
- extract($args);
567
- $options = get_option("most_recommended_posts");
568
- if (!is_array( $options )) {
569
- $options = array(
570
- 'title' => 'Most recommended posts',
571
- 'number' => '5',
572
- 'show_count' => '0'
573
- );
574
- }
575
- $title = $options['title'];
576
- $numberOf = $options['number'];
577
- $show_count = $options['show_count'];
578
-
579
- echo $before_widget;
580
- echo $before_title . $title . $after_title;
581
- echo '<ul class="mostrecommendedposts">';
582
-
583
- most_recommended_posts($numberOf, '<li>', '</li>', $show_count);
584
-
585
- echo '</ul>';
586
- echo $after_widget;
587
- }
588
- wp_register_sidebar_widget('most_recommended_posts', 'Most recommended posts', 'widget_most_recommended_posts');
589
-
590
- function options_widget_most_recommended_posts() {
591
- $options = get_option("most_recommended_posts");
592
-
593
- if (!is_array( $options )) {
594
- $options = array(
595
- 'title' => 'Most recommended posts',
596
- 'number' => '5',
597
- 'show_count' => '0'
598
- );
599
- }
600
-
601
- if ($_POST['mrp-submit']) {
602
- $options['title'] = htmlspecialchars($_POST['mrp-title']);
603
- $options['number'] = htmlspecialchars($_POST['mrp-number']);
604
- $options['show_count'] = $_POST['mrp-show-count'];
605
- if ( $options['number'] > 15) { $options['number'] = 15; }
606
-
607
- update_option("most_recommended_posts", $options);
608
- }
609
- ?>
610
- <p><label for="mrp-title"><?php _e('Title:', 'i-recommend-this'); ?><br />
611
- <input class="widefat" type="text" id="mrp-title" name="mrp-title" value="<?php echo $options['title'];?>" /></label></p>
612
-
613
- <p><label for="mrp-number"><?php _e('Number of posts to show:', 'i-recommend-this'); ?><br />
614
- <input type="text" id="mrp-number" name="mrp-number" style="width: 25px;" value="<?php echo $options['number'];?>" /> <small>(max. 15)</small></label></p>
615
-
616
- <p><label for="mrp-show-count"><input type="checkbox" id="mrp-show-count" name="mrp-show-count" value="1"<?php if($options['show_count'] == '1') echo 'checked="checked"'; ?> /> <?php _e('Show post count', 'i-recommend-this'); ?></label></p>
617
-
618
- <input type="hidden" id="mrp-submit" name="mrp-submit" value="1" />
619
- <?php
620
- }
621
- wp_register_widget_control('most_recommended_posts', 'Most recommended posts', 'options_widget_most_recommended_posts');
622
- }
623
-
624
- add_action('init', 'add_widget_most_recommended_posts');
625
- ####
626
-
627
-
628
- #### FRONT-END VIEW ####
629
- function getIRecommendThis($arg) {
630
- global $wpdb;
631
- $post_ID = get_the_ID();
632
- $ip = $_SERVER['REMOTE_ADDR'];
633
-
634
- $recommended = get_post_meta($post_ID, '_recommended', true) != '' ? get_post_meta($post_ID, '_recommended', true) : '0';
635
- $voteStatusByIp = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."irecommendthis_votes WHERE post_id = '$post_ID' AND ip = '$ip'");
636
-
637
- /*
638
- if (!isset($_COOKIE['recommended-'.$post_ID]) && $voteStatusByIp == 0) {
639
- //$counter = '<a onclick="likeThis('.$post_ID.');">'.$liked.'';
640
- //$counter = '<a onclick="likeThis('.$post_ID.');" class"image">'.$liked.'</a>';
641
- $counter = $recommended;
642
- $recommend_status = "";
643
- }
644
- else {
645
- $counter = $recommended;
646
- $recommend_status = "active";
647
- }
648
- */
649
- if (!isset($_COOKIE['recommended-'.$post_ID]) && $voteStatusByIp == 0) {
650
- if (get_option('irt_textOrNotext') == 'notext') {
651
- $counter = '<a onclick="recommendThis('.$post_ID.');" class="recommendThis">'.$recommended.'</a>';
652
- }
653
- else {
654
- $counter = '<a onclick="recommendThis('.$post_ID.');" class="recommendThis">'.$recommended.' - '.get_option('irt_text').'</a>';
655
- }
656
- }
657
- else {
658
- $counter = '<a onclick="return(false);" class="recommendThis active">'.$recommended.'</a>';
659
- }
660
- //END of modifed part
661
-
662
-
663
- /*
664
- $iRecommendThis = '<div id="iRecommendThis-'.$post_ID.'" class="iRecommendThis"><a onclick="recommendThis('.$post_ID.');" class="'.$recommend_status.'">';
665
- $iRecommendThis .= '<span class="counter">'.$counter.'</span>';
666
- $iRecommendThis .= '</a></div>';
667
- */
668
- $iRecommendThis = '<div id="iRecommendThis-'.$post_ID.'" class="iRecommendThis">';
669
- $iRecommendThis .= $counter;
670
- $iRecommendThis .= '</div>';
671
-
672
- //END of modifed part
673
- /*
674
- if ($arg == 'put') {
675
- return $iRecommendThis;
676
- }
677
- else {
678
- echo $iRecommendThis;
679
- }
680
- }
681
- */
682
-
683
- if ($arg == 'put') {
684
- return $iRecommendThis;
685
- }
686
- else if ($arg == 'count'){
687
- echo $recommended;
688
- }
689
- else {
690
- echo $iRecommendThis;
691
- }
692
- }
693
- //END of modifed part
694
-
695
- if (get_option('irt_onPage') == '1') {
696
- function putIRecommendThis($content) {
697
- if(!is_feed() && !is_page()) {
698
- $content.= getIRecommendThis('put');
699
- }
700
- return $content;
701
- }
702
-
703
- add_filter('the_content', putIRecommendThis);
704
- }
705
-
706
- function enqueueScripts() {
707
- if (get_option('irt_jquery') == '1') {
708
- wp_enqueue_script('iRecommendThis', WP_PLUGIN_URL.'/i-recommend-this/js/i-recommend-this.js', array('jquery'));
709
- }
710
- else {
711
- wp_enqueue_script('iRecommendThis', WP_PLUGIN_URL.'/i-recommend-this/js/i-recommend-this.js');
712
- }
713
- }
714
-
715
- function addHeaderLinks() {
716
- echo '<link rel="stylesheet" type="text/css" href="'.WP_PLUGIN_URL.'/i-recommend-this/css/i-recommend-this.css" media="screen" />'."\n";
717
- echo '<script type="text/javascript">var blogUrl = \''.get_bloginfo('wpurl').'\'</script>'."\n";
718
- }
719
-
720
- add_action('init', enqueueScripts);
721
- add_action('wp_head', addHeaderLinks);
722
- ?>
3
  Plugin Name: I Recommend This
4
  Plugin URI: http://www.harishchouhan.com/personal-projects/i-recommend-this/
5
  Description: This plugin allows your visitors to simply recommend or like your posts instead of commment it.
6
+ Version: 1.4.2
7
  Author: Harish Chouhan
8
  Author URI: http://www.harishchouhan.com
9
 
363
 
364
  add_action('init', enqueueScripts);
365
  add_action('wp_head', addHeaderLinks);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.designerskiosk.com
4
  Tags: recommend, like, love, post, rate, rating, heart
5
  Requires at least: 3.0
6
  Tested up to: 3.2.2
7
- Stable tag: 1.4.1
8
  Last Updated: 2012-May-15
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
4
  Tags: recommend, like, love, post, rate, rating, heart
5
  Requires at least: 3.0
6
  Tested up to: 3.2.2
7
+ Stable tag: 1.4.2
8
  Last Updated: 2012-May-15
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html