Plugin Directory

Changeset 916674


Ignore:
Timestamp:
05/18/2014 05:45:29 PM (12 years ago)
Author:
dkukral
Message:

verified compat with wp 3.9.1

Location:
social-referrals/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • social-referrals/trunk/license.txt

    r516863 r916674  
    11WordPress - Web publishing software
    22
    3 Copyright 2012 by the contributors
     3Copyright 2014 by the contributors
    44
    55This program is free software; you can redistribute it and/or modify
     
    3232  WordPress - Web publishing software
    3333
    34   Copyright 2003-2012 by the contributors
     34  Copyright 2003-2014 by the contributors
    3535
    3636  WordPress is released under the GPL
  • social-referrals/trunk/readme.txt

    r621888 r916674  
    11=== Social Referrals ===
    2 Contributors: jboydston, dkukral, Droyal
     2Contributors: jboydston, dkukral
    33Tags: social, facebook, twitter, statistics
    44Requires at least: 3.0
    55Tested up to: 3.3.1
    6 Stable Tag: 1.2
     6Stable Tag: 1.4
    77
    88Plugin for WordPress logs social site referrals and provides shortcodes for displaying them.
     
    1313
    1414== License ==
    15 Copyright 2010 - 2012 Joe Boydston, Don Kukral
     15Copyright 2010 - 2014 Joe Boydston, Don Kukral
    1616
    1717This program is free software; you can redistribute it and/or modify
     
    3131== Installation ==
    3232
    33 Copy "social-referrals" folder to your WordPress Plugins Directory. 
     33Copy "social-referrals" folder to your WordPress Plugins Directory.
    3434Activate plugin via WordPress settings.
    3535
     
    3838No shortcodes yet .. but it does keep track of the number of referrals in the last 24 hours.
    3939
    40 Two WP options are set with these values and updated whenever a new referrer is logged. 
     40Two WP options are set with these values and updated whenever a new referrer is logged.
    4141
    4242social_referrals_facebook_count
     
    4848
    4949== Changelog ==
     50= 1.4 =
     51Verified compat with WP 3.9.1
    5052
    51 = 1.2 =
     53= 1.3 =
     54Added wordpress.com tracker
     55
     56= 1.2 =
    5257Fixed hardcoded table name
    5358
    54 = 1.1 = 
     59= 1.1 =
    5560Added setting to custom how many hours back to display of the count.
    5661
    57 = 1.0 = 
     62= 1.0 =
    5863Initial version
    5964
  • social-referrals/trunk/social-referrals.php

    r518927 r916674  
    44Plugin URI: http://yourdomain.com/
    55Description: Logs and displays social site referrals
    6 Version: 1.2
     6Version: 1.4
    77Author: Don Kukral
    88Author URI: http://yourdomain.com
     
    1919         $ref_url = parse_url($_SERVER['HTTP_REFERER']);
    2020         if ($ref_url['host'] == 't.co') {
    21              social_referrals_log_entry($post->ID, $_SERVER['HTTP_REFERER'], 0, 1);
     21             social_referrals_log_entry($post->ID, $_SERVER['HTTP_REFERER'], 0, 1, 0);
    2222             return;
    2323         }
     
    2727        $ref_url = parse_url($_SERVER['HTTP_REFERER']);
    2828         if (($ref_url['host'] == 'www.facebook.com') || ($ref_url['host'] == 'm.facebook.com')) {
    29              social_referrals_log_entry($post->ID, $_SERVER['HTTP_REFERER'], 1, 0);
     29             social_referrals_log_entry($post->ID, $_SERVER['HTTP_REFERER'], 1, 0, 0);
     30             return;
     31         }
     32     }
     33
     34    if (get_option('social_referrals_wordpress', 0)) {
     35        $ref_url = parse_url($_SERVER['HTTP_REFERER']);
     36         if (($ref_url['host'] == 'www.wordpress.com')) {
     37             social_referrals_log_entry($post->ID, $_SERVER['HTTP_REFERER'], 1, 0, 0);
    3038             return;
    3139         }
     
    3341}
    3442
    35 function social_referrals_log_entry($post_id, $referral_url, $facebook, $twitter) {
     43function social_referrals_log_entry($post_id, $referral_url, $facebook, $twitter, $wordpress) {
    3644    global $wpdb;
    3745    $table_name = $wpdb->prefix . "social_referrals";
    3846    $wpdb->insert(
    39         $table_name, 
     47        $table_name,
    4048        array(
    4149            'post_id' => $post_id,
    4250            'referral_url' => $referral_url,
    4351            'facebook' => $facebook,
    44             'twitter' => $twitter
     52            'twitter' => $twitter,
     53            'wordpress' => $wordpress
    4554        ),
    4655        array(
     
    4857            '%s',
    4958            '%d',
     59            '%d',
    5060            '%d'
    5161        )
    5262    );
    53     $row = $wpdb->get_row("SELECT SUM(facebook) AS facebook, SUM(twitter) AS twitter FROM " . $wpdb->prefix . "social_referrals WHERE ts > NOW() - INTERVAL " . get_option('social_referrals_hours', 24) . " HOUR");
     63    $row = $wpdb->get_row("SELECT SUM(facebook) AS facebook, SUM(twitter) AS twitter, SUM(wordpress) as wordpress FROM " . $wpdb->prefix . "social_referrals WHERE ts > NOW() - INTERVAL " . get_option('social_referrals_hours', 24) . " HOUR");
    5464    update_option('social_referrals_facebook_count', $row->facebook);
    5565    update_option('social_referrals_twitter_count', $row->twitter);
    56    
     66    update_option('social_referrals_wordpress_count', $row->wordpress);
     67
    5768}
    5869
    5970function social_referrals_admin_menu() {
    6071    add_options_page(
    61         'Social Referrals', 
    62         'Social Referrals', 
     72        'Social Referrals',
     73        'Social Referrals',
    6374        'administrator',
    64         'social_referrals', 
     75        'social_referrals',
    6576        'social_referrals_settings_page');
    6677}
     
    7283        if ($_POST['social_referrals_twitter']) { update_option('social_referrals_twitter', 1); }
    7384        else { delete_option('social_referrals_twitter'); }
     85        if ($_POST['social_referrals_wordpress']) { update_option('social_referrals_wordpress', 1); }
     86        else { delete_option('social_referrals_wordpress'); }
    7487        if ($_POST['social_referrals_hours']) { update_option('social_referrals_hours', $_POST['social_referrals_hours']); }
    7588        else { update_option('social_referrals_hours', '24'); }
     
    8497            <input type="hidden" name="action" value="update" />
    8598            <?php wp_nonce_field('update-options'); ?>
    86            
     99
    87100            <table class="form-table">
    88101            <tr>
     
    92105            <td><input type="checkbox" name="social_referrals_twitter" <?php echo checked(get_option('social_referrals_twitter'), 1); ?>/> Track Twitter referrals.</td>
    93106            </tr>
     107            <tr>
     108            <td><input type="checkbox" name="social_referrals_wordpress" <?php echo checked(get_option('social_referrals_wordpress'), 1); ?>/> Track Wordpress.com referrals.</td>
     109            </tr>
    94110            <tr>
    95111            <tr>
     
    110126    global $wpdb;
    111127    global $social_referrals_db_ver;
    112    
     128
    113129    $table_name = $wpdb->prefix . "social_referrals";
    114    
     130
    115131    $sql = "CREATE TABLE " . $table_name . " (
    116132        id MEDIUMINT(9) NOT NULL AUTO_INCREMENT,
     
    121137        ts TIMESTAMP NOT NULL,
    122138        UNIQUE KEY id (id));";
    123    
     139
    124140    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    125141    dbDelta($sql);
    126    
     142
    127143    $social_referrals_db_ver = 1.0;
    128144    add_option("social_referrals_db_ver", $social_referrals_db_ver);
    129    
     145
    130146}
    131147
    132148register_activation_hook(__FILE__, 'social_referrals_install');
    133149
     150function social_referrals_db_update() {
     151    global $wpdb;
     152
     153    $curr_social_referrals_ver = 1.1;
     154    $social_referrals_db_ver = get_option("social_referrals_db_ver", 0);
     155
     156    if ($social_referrals_db_ver == 0) { social_referrals_install(); }
     157    $social_referrals_db_ver = get_option("social_referrals_db_ver", 0);
     158
     159    if ($social_referrals_db_ver < 1.1) {
     160        $table_name = $wpdb->prefix . "social_referrals";
     161
     162        $sql = "CREATE TABLE " . $table_name . " (
     163            id MEDIUMINT(9) NOT NULL AUTO_INCREMENT,
     164            post_id BIGINT(20) NOT NULL DEFAULT 0,
     165            referral_url TEXT NOT NULL DEFAULT '',
     166            facebook INT(11) NOT NULL DEFAULT 0,
     167            twitter INT(11) NOT NULL DEFAULT 0,
     168            wordpress INT(11) NOT NULL DEFAULT 0,
     169            ts TIMESTAMP NOT NULL,
     170            UNIQUE KEY id (id));";
     171
     172        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
     173        dbDelta($sql);
     174        $social_referrals_db_ver = 1.1;
     175        add_option("social_referrals_db_ver", $social_referrals_db_ver);
     176    }
     177}
     178
     179//add_action( 'plugins_loaded', 'social_referrals_db_update' );
     180
    134181?>
Note: See TracChangeset for help on using the changeset viewer.