Changeset 916674
- Timestamp:
- 05/18/2014 05:45:29 PM (12 years ago)
- Location:
- social-referrals/trunk
- Files:
-
- 3 edited
-
license.txt (modified) (2 diffs)
-
readme.txt (modified) (5 diffs)
-
social-referrals.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
social-referrals/trunk/license.txt
r516863 r916674 1 1 WordPress - Web publishing software 2 2 3 Copyright 201 2by the contributors3 Copyright 2014 by the contributors 4 4 5 5 This program is free software; you can redistribute it and/or modify … … 32 32 WordPress - Web publishing software 33 33 34 Copyright 2003-201 2by the contributors34 Copyright 2003-2014 by the contributors 35 35 36 36 WordPress is released under the GPL -
social-referrals/trunk/readme.txt
r621888 r916674 1 1 === Social Referrals === 2 Contributors: jboydston, dkukral , Droyal2 Contributors: jboydston, dkukral 3 3 Tags: social, facebook, twitter, statistics 4 4 Requires at least: 3.0 5 5 Tested up to: 3.3.1 6 Stable Tag: 1. 26 Stable Tag: 1.4 7 7 8 8 Plugin for WordPress logs social site referrals and provides shortcodes for displaying them. … … 13 13 14 14 == License == 15 Copyright 2010 - 201 2Joe Boydston, Don Kukral15 Copyright 2010 - 2014 Joe Boydston, Don Kukral 16 16 17 17 This program is free software; you can redistribute it and/or modify … … 31 31 == Installation == 32 32 33 Copy "social-referrals" folder to your WordPress Plugins Directory. 33 Copy "social-referrals" folder to your WordPress Plugins Directory. 34 34 Activate plugin via WordPress settings. 35 35 … … 38 38 No shortcodes yet .. but it does keep track of the number of referrals in the last 24 hours. 39 39 40 Two WP options are set with these values and updated whenever a new referrer is logged. 40 Two WP options are set with these values and updated whenever a new referrer is logged. 41 41 42 42 social_referrals_facebook_count … … 48 48 49 49 == Changelog == 50 = 1.4 = 51 Verified compat with WP 3.9.1 50 52 51 = 1.2 = 53 = 1.3 = 54 Added wordpress.com tracker 55 56 = 1.2 = 52 57 Fixed hardcoded table name 53 58 54 = 1.1 = 59 = 1.1 = 55 60 Added setting to custom how many hours back to display of the count. 56 61 57 = 1.0 = 62 = 1.0 = 58 63 Initial version 59 64 -
social-referrals/trunk/social-referrals.php
r518927 r916674 4 4 Plugin URI: http://yourdomain.com/ 5 5 Description: Logs and displays social site referrals 6 Version: 1. 26 Version: 1.4 7 7 Author: Don Kukral 8 8 Author URI: http://yourdomain.com … … 19 19 $ref_url = parse_url($_SERVER['HTTP_REFERER']); 20 20 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); 22 22 return; 23 23 } … … 27 27 $ref_url = parse_url($_SERVER['HTTP_REFERER']); 28 28 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); 30 38 return; 31 39 } … … 33 41 } 34 42 35 function social_referrals_log_entry($post_id, $referral_url, $facebook, $twitter ) {43 function social_referrals_log_entry($post_id, $referral_url, $facebook, $twitter, $wordpress) { 36 44 global $wpdb; 37 45 $table_name = $wpdb->prefix . "social_referrals"; 38 46 $wpdb->insert( 39 $table_name, 47 $table_name, 40 48 array( 41 49 'post_id' => $post_id, 42 50 'referral_url' => $referral_url, 43 51 'facebook' => $facebook, 44 'twitter' => $twitter 52 'twitter' => $twitter, 53 'wordpress' => $wordpress 45 54 ), 46 55 array( … … 48 57 '%s', 49 58 '%d', 59 '%d', 50 60 '%d' 51 61 ) 52 62 ); 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"); 54 64 update_option('social_referrals_facebook_count', $row->facebook); 55 65 update_option('social_referrals_twitter_count', $row->twitter); 56 66 update_option('social_referrals_wordpress_count', $row->wordpress); 67 57 68 } 58 69 59 70 function social_referrals_admin_menu() { 60 71 add_options_page( 61 'Social Referrals', 62 'Social Referrals', 72 'Social Referrals', 73 'Social Referrals', 63 74 'administrator', 64 'social_referrals', 75 'social_referrals', 65 76 'social_referrals_settings_page'); 66 77 } … … 72 83 if ($_POST['social_referrals_twitter']) { update_option('social_referrals_twitter', 1); } 73 84 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'); } 74 87 if ($_POST['social_referrals_hours']) { update_option('social_referrals_hours', $_POST['social_referrals_hours']); } 75 88 else { update_option('social_referrals_hours', '24'); } … … 84 97 <input type="hidden" name="action" value="update" /> 85 98 <?php wp_nonce_field('update-options'); ?> 86 99 87 100 <table class="form-table"> 88 101 <tr> … … 92 105 <td><input type="checkbox" name="social_referrals_twitter" <?php echo checked(get_option('social_referrals_twitter'), 1); ?>/> Track Twitter referrals.</td> 93 106 </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> 94 110 <tr> 95 111 <tr> … … 110 126 global $wpdb; 111 127 global $social_referrals_db_ver; 112 128 113 129 $table_name = $wpdb->prefix . "social_referrals"; 114 130 115 131 $sql = "CREATE TABLE " . $table_name . " ( 116 132 id MEDIUMINT(9) NOT NULL AUTO_INCREMENT, … … 121 137 ts TIMESTAMP NOT NULL, 122 138 UNIQUE KEY id (id));"; 123 139 124 140 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 125 141 dbDelta($sql); 126 142 127 143 $social_referrals_db_ver = 1.0; 128 144 add_option("social_referrals_db_ver", $social_referrals_db_ver); 129 145 130 146 } 131 147 132 148 register_activation_hook(__FILE__, 'social_referrals_install'); 133 149 150 function 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 134 181 ?>
Note: See TracChangeset
for help on using the changeset viewer.