WordPress.org

Plugin Directory

Changeset 334139


Ignore:
Timestamp:
01/18/11 14:07:38 (7 years ago)
Author:
nikolay.yordanov
Message:

2.2

Location:
like-it/trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • like-it/trunk/like-it.php

    r295999 r334139  
    44Plugin URI: http://nyordanov.com/projects 
    55Description: Like-it allows post readers mark their approval of a post by clicking the Like-it button, instead of posting yet another "I like this post" comment 
    6 Version: 2.0 
     6Version: 2.2 
    77Author: Nikolay Yordanov 
    88Author URI: http://nyordanov.com 
     
    5757        dbDelta($sql); 
    5858 
    59         add_option("likeit_dbVersion", $likeit_dbVersion); 
     59        update_option("likeit_dbVersion", $likeit_dbVersion); 
    6060    } 
    6161     
    6262    add_option('likeit-text', 'Like!', '', 'yes'); 
    6363    add_option('likeit-autodisplay', 'on', '', 'yes'); 
     64    add_option('likeit-per-page', '30', '', 'yes'); 
    6465} 
    6566 
     
    7677} 
    7778 
    78 // register plugin config 
     79// add menus 
    7980 
    8081add_action('admin_menu', 'likeit_config_page'); 
    8182function likeit_config_page() { 
    82     if ( function_exists('add_options_page') ) 
    83         add_options_page(__('Like-it Configuration'), __('Like-it Configuration'), 'manage_options', 'likeit-config', 'likeit_conf'); 
     83    if(function_exists('add_menu_page')) 
     84        add_menu_page( __('Like-it'), __('Like-it'), 'manage_options', 'likeit', 'likeit_stats' ); 
     85    if(function_exists('add_submenu_page')) { 
     86        add_submenu_page( 'likeit', __('Like-it Stats'), __('Like-it Stats'), 'manage_options', 'likeit', 'likeit_stats'); 
     87        add_submenu_page( 'likeit', __('Like-it Configuration'), __('Like-it Configuration'), 'manage_options', 'likeit_conf', 'likeit_conf'); 
     88    } 
     89} 
     90 
     91// statistics page 
     92 
     93function likeit_stats() { 
     94    global $wpdb, $likeit_table; 
     95 
     96    $page = (isset($_GET['paged'])) ? intval($_GET['paged']) : 1; 
     97    $likeit_per_page = get_option('likeit-per-page'); 
     98    $from = ($page-1) * $likeit_per_page; 
     99    $likes = $wpdb->get_results("SELECT * FROM $likeit_table LIMIT $from, $likeit_per_page"); 
     100     
     101    foreach($likes as &$like) { 
     102        $ipinfo_url = 'http://ipinfodb.com/ip_query.php?ip='.$like->ip.'&output=json&timezone=false'; 
     103        if(function_exists('curl_init')) { 
     104            $request = curl_init(); 
     105            curl_setopt($request, CURLOPT_URL, $ipinfo_url); 
     106            curl_setopt($request, CURLOPT_RETURNTRANSFER, true); 
     107            $like->ip_info = curl_exec($request); 
     108            curl_close($request); 
     109        } 
     110        else 
     111            $like->ip_info = file_get_contents($ipinfo_url); 
     112 
     113        $like->ip_info = json_decode($like->ip_info); 
     114         
     115        $like->post_url = get_permalink($like->post_id); 
     116        $like->post_title = get_post($like->post_id)->post_title; 
     117         
     118        $like->post_liked_count = likeit_get_count_by_post_id($like->post_id); 
     119    } 
     120 
     121    $total_likes = $wpdb->get_var("SELECT COUNT(*) FROM $likeit_table"); 
     122     
     123    require('tpl/stats.php'); 
    84124} 
    85125 
     
    87127 
    88128function likeit_conf() { 
    89  
    90     $opt_name = 'mt_favorite_color'; 
    91     $data_field_name = 'mt_favorite_color'; 
    92  
    93     $opt_val = get_option( $opt_name ); 
    94129     
    95130    if( isset($_POST['likeit-text']) ) { 
     
    109144 
    110145// add javascript 
    111 add_action('wp_print_scripts', likeit_scripts); 
     146add_action('wp_print_scripts', 'likeit_scripts'); 
    112147function likeit_scripts() { 
    113148    wp_enqueue_script( 'likeit', plugin_dir_url(__FILE__). 'content/like-it.js', array('jquery'), '0.1'); 
     
    116151 
    117152// add css 
    118 add_action('wp_print_styles', likeit_styles); 
     153add_action('wp_print_styles', 'likeit_styles'); 
    119154function likeit_styles() { 
    120155    wp_enqueue_style('likeit', plugin_dir_url(__FILE__).'content/like-it.css', false, '0.1', 'all'); 
     
    122157 
    123158// add filter to echo the Like-it button 
    124 add_filter('the_content', likeit_button_filter); 
     159add_filter('the_content', 'likeit_button_filter'); 
    125160function likeit_button_filter($content) { 
    126161    if( !(is_page() || is_feed()) && get_option('likeit-autodisplay') == 'on' ) 
     
    137172function likeit_get_button() { 
    138173    $canvote = likeit_can_vote(get_the_ID(), $_SERVER['REMOTE_ADDR']) ? 'likeit-canvote' : 'likeit-voted'; 
    139     $text = get_option('likeit-text'); 
     174    $text = stripslashes(get_option('likeit-text')); 
    140175    $id = get_the_ID(); 
    141176    $count = likeit_get_count_by_post_id($id); 
  • like-it/trunk/readme.txt

    r295999 r334139  
    44Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=2A38D8TGNFPGA&lc=BG&item_name=Nikolay%20Yordanov&item_number=Like%2dit%20donation&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted 
    55Requires at least: 2.9 
    6 Tested up to: 3.0.1 
    7 Stable tag: 2.0 
     6Tested up to: 3.0.4 
     7Stable tag: 2.2 
    88 
    99Like-it allows visitors to just "like" a post, preventing multiple meaningless comments or providing a faster user experience. 
     
    1919== Changelog == 
    2020 
     21= 2.2 = 
     22 
     23* Links to post in the widget haven't been displayed  
     24 
     25= 2.1 = 
     26 
     27* Added statistics page  
     28** IP 
     29** Geolocation 
     30** Time 
     31** Post title 
     32 
    2133= 2.0 = 
    2234 
  • like-it/trunk/tpl/config.php

    r285950 r334139  
    3535        <tr> 
    3636            <th scope="row"><label for="likeit-text"><?php _e('Like-it button text') ?></label></th> 
    37             <td><input type="text" id="likeit-text" name="likeit-text" value="<?php echo get_option('likeit-text')?>" /></td> 
     37            <td><input type="text" id="likeit-text" name="likeit-text" value="<?php echo stripslashes(get_option('likeit-text'))?>" /></td> 
    3838        </tr> 
    3939        <tr> 
     
    4343                <label for="likeit-autodisplay">Append button to the end of each post</label> 
    4444                <br /> 
    45                 <span class="description"><?php _e('If you want to place it elsewhere, you may use <code>&lt?php likeit_button(); ?&gt;</code> in your theme, but remember that it uses <code>get_the_ID()</code> to get current post\'s id') ?></span> 
     45                <span class="description"><?php _e('If you want to place it elsewhere, you may use <code>&lt?php if(function_exists("likeit_button")) likeit_button(); ?&gt;</code> in your theme, but remember that it uses <code>get_the_ID()</code> to get current post\'s id') ?></span> 
    4646            </td> 
    4747        </tr> 
  • like-it/trunk/tpl/widget.php

    r295999 r334139  
    11<ul class="likeit-widget-posts"> 
    2 <?php foreach($posts as $post): ?> 
     2<?php foreach($posts as $lpost): ?> 
    33 
    4 <?php $post_data = get_post($post->post_id, OBJECT); ?> 
     4<?php $post_data = get_post($lpost->post_id, OBJECT); ?> 
    55 
    66    <li> 
    77        <h4> 
    8             <a href="<?php get_permalink($post->post_id) ?>" title="<?php echo $post_data->post_title ?>"> 
    9             <?php echo $post_data->post_title ?> (<?php echo $post->likes ?>) 
     8            <a href="<?php echo get_permalink($lpost->post_id) ?>" title="<?php echo $post_data->post_title ?>"> 
     9            <?php echo $post_data->post_title ?> (<?php echo $lpost->likes ?>) 
    1010            </a> 
    1111        </h4> 
  • like-it/trunk/widget.php

    r295999 r334139  
    2222        $instance['title'] = strip_tags($new_instance['title']); 
    2323        $instance['displayed'] = strip_tags($new_instance['displayed']); 
    24         return $instance; 
     24        return $instance; 
    2525    } 
    2626 
Note: See TracChangeset for help on using the changeset viewer.