Changeset 1379030
- Timestamp:
- 03/25/2016 08:15:25 PM (10 years ago)
- Location:
- wp-cloaker
- Files:
-
- 31 added
- 7 edited
-
tags/1.0.5 (added)
-
tags/1.0.5/README.txt (added)
-
tags/1.0.5/assets (added)
-
tags/1.0.5/assets/banner-772x250.jpg (added)
-
tags/1.0.5/assets/css (added)
-
tags/1.0.5/assets/css/wp-cloaker.css (added)
-
tags/1.0.5/assets/js (added)
-
tags/1.0.5/assets/js/ZeroClipboard.min.js (added)
-
tags/1.0.5/assets/js/ZeroClipboard.min.map (added)
-
tags/1.0.5/assets/js/ZeroClipboard.swf (added)
-
tags/1.0.5/assets/js/copy.js (added)
-
tags/1.0.5/assets/js/reports.js (added)
-
tags/1.0.5/assets/js/wp-cloaker.js (added)
-
tags/1.0.5/assets/views (added)
-
tags/1.0.5/assets/views/_notes (added)
-
tags/1.0.5/assets/views/clicks_details.php (added)
-
tags/1.0.5/assets/views/images (added)
-
tags/1.0.5/assets/views/images/hire-us.png (added)
-
tags/1.0.5/assets/views/images/wp-cloaker-logo.png (added)
-
tags/1.0.5/assets/views/link-options.php (added)
-
tags/1.0.5/assets/views/reports.php (added)
-
tags/1.0.5/assets/views/settings.php (added)
-
tags/1.0.5/assets/views/single-wp_cloaker_link.php (added)
-
tags/1.0.5/classes (added)
-
tags/1.0.5/classes/Add_Taxonomy_To_Post_Permalinks.php (added)
-
tags/1.0.5/classes/class-wp-cloaker-admin.php (added)
-
tags/1.0.5/classes/class-wp-cloaker-clicks.php (added)
-
tags/1.0.5/classes/class-wp-cloaker-reports.php (added)
-
tags/1.0.5/classes/class-wp-cloaker.php (added)
-
tags/1.0.5/uninstall.php (added)
-
tags/1.0.5/wp-cloaker.php (added)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/assets/views/single-wp_cloaker_link.php (modified) (2 diffs)
-
trunk/classes/class-wp-cloaker-admin.php (modified) (2 diffs)
-
trunk/classes/class-wp-cloaker-clicks.php (modified) (7 diffs)
-
trunk/classes/class-wp-cloaker.php (modified) (1 diff)
-
trunk/uninstall.php (modified) (3 diffs)
-
trunk/wp-cloaker.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-cloaker/trunk/README.txt
r1374737 r1379030 5 5 Requires at least: 4.0.0 6 6 Tested up to: 4.4.2 7 Stable tag: 1.0. 47 Stable tag: 1.0.5 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 17 17 From the reports page you can generate reports and filter by Link Title, Month/Year, Link category OR country. 18 18 19 Here are someFeatures of **WP Cloaker** plugin:19 Features of **WP Cloaker** plugin: 20 20 21 21 1. Hide, shorten your links. 22 2. Custom redirection type: 301,302,303,307 and Javascript redirection. 22 2. Custom redirection type: 301,302,303,307 and Javascript redirection. 23 23 3. Categorize your links. 24 4. Custom permalinks e.g : www.yoursite.com/visit/link-category-slug/link-slug. 25 5. Track links clicks, each time a visitor click on any link, the plugin will store the visitor information like (IP address, click date/time, Country, etc..). 26 6. Generate clicks reports with some options to filter the report. 24 4. Custom permalink prefix e.g: (go,out,visit, etc.). 25 5. Custom permalinks e.g : www.yoursite.com/visit/link-category-slug/link-slug. 26 6. Track links clicks, each time a visitor click on any link, the plugin will store the visitor information like (IP address, click date/time, Country, etc..). 27 7. Generate clicks reports with some options to filter the report. 28 8. Option to disable collecting data on link redirection ( it will make redirection much faster). 29 27 30 28 31 If you have any question or features request, please don't hesitiate to contact us at support[@]wwgate.net … … 86 89 = 1.0.4 = 87 90 add warning message to settings page 91 92 = 1.0.5 = 93 1. delete wp_cloaker_version option when uninstall. 94 2. wp_cloaker_clicks_count table deleted. 95 4. added option to disable collecting data on redirection. 96 97 98 -
wp-cloaker/trunk/assets/views/single-wp_cloaker_link.php
r1371076 r1379030 1 1 <?php 2 3 require_once(wp_cloaker_path.'classes/class-wp-cloaker-clicks.php');4 2 $linkOptions = get_post_meta($post->ID); 5 3 $link = $linkOptions['wp_cloaker_link'][0]; 6 4 7 8 9 /*//print out 3rd parthy traking code10 if(get_option( 'wp_cloaker_link_tracking_code')){11 echo "<script>". esc_attr( get_option( 'wp_cloaker_link_tracking_code' ) )."</script>";12 }*/13 5 $cusOptions = $linkOptions['wp_cloaker_link_custom_options'][0]; 14 6 if($cusOptions){ … … 17 9 $redirect = esc_attr( get_option( 'wp_cloaker_link_redirection','301' ) ); 18 10 } 19 //get visitor information from IP-API 20 //get link category id 21 $terms = wp_get_post_terms( $post->ID, 'wp_cloaker_link_category'); 22 $term_id = ( !empty($terms) ) ? $terms[0]->term_id : null; 23 //add visitor information to db 24 $clicks = new WP_Cloaker_Clicks(); 25 //register this click to db 26 $clicks->wp_cloaker_click_count( $post->ID,$term_id); 27 $clicks->getIPInfo($post->ID); 11 echo get_option('wp_cloaker_link_collect_data','yes'); 12 if(get_option('wp_cloaker_link_collect_data','yes') == 'yes'){ 28 13 14 //get visitor information 15 //add visitor information to db 16 require_once(wp_cloaker_path.'classes/class-wp-cloaker-clicks.php'); 17 $clicks = new WP_Cloaker_Clicks(); 18 //register this click to db 19 $clicks->getIPInfo($post->ID); 20 } 29 21 30 22 switch($redirect){ -
wp-cloaker/trunk/classes/class-wp-cloaker-admin.php
r1374737 r1379030 127 127 add_settings_field( 'wp_cloaker_link_redirection', 'Link Redirection', array($this,'wp_cloaker_link_redirection_callback'), 'wp_cloaker_link_settings', 'default_settings' ); 128 128 129 register_setting( 'wp_cloaker_settings_group', 'wp_cloaker_link_collect_data' ); 130 add_settings_field( 'wp_cloaker_link_collect_data', 'Collect user data on redirection', array($this,'wp_cloaker_link_collect_data_callback'), 'wp_cloaker_link_settings', 'default_settings' ); 131 129 132 /*register_setting( 'wp_cloaker_settings_group', 'wp_cloaker_link_cat_prefix' ); 130 133 add_settings_field( 'wp_cloaker_link_cat_prefix', 'Include Category Slug in link url?', array($this,'wp_cloaker_link_cat_prefix_callback'), 'wp_cloaker_link_settings', 'default_settings' ); … … 155 158 <option value="307" <?php echo $linkRedirection == "307" ? 'selected="selected"':''; ?>>307 redirection</option> 156 159 <option value="js" <?php echo $linkRedirection == "js" ? 'selected="selected"':''; ?>>JavaScript redirection</option> 160 </select><?php 161 } 162 public function wp_cloaker_link_collect_data_callback(){ 163 $collect = esc_attr( get_option( 'wp_cloaker_link_collect_data','1' ) );?> 164 <select name="wp_cloaker_link_collect_data"> 165 <option value="yes" <?php echo $collect == "yes" ? 'selected="selected"':''; ?>>Yes</option> 166 <option value="no" <?php echo $collect == "no" ? 'selected="selected"':''; ?>>No</option> 157 167 </select><?php 158 168 } -
wp-cloaker/trunk/classes/class-wp-cloaker-clicks.php
r1371080 r1379030 15 15 global $wpdb; 16 16 $wpdb->wp_cloaker_clicks_table = "{$wpdb->prefix}cloaker_clicks"; 17 $wpdb->wp_cloaker_clicks_count_table = "{$wpdb->prefix}cloaker_clicks_count";18 17 } 19 18 … … 40 39 ) $charset_collate"; 41 40 dbDelta($create_table_sql); 41 42 $v = get_option('wp_cloaker_version','1.0.4'); 43 if( version_compare($v,'1.0.5') < 0 ){ 44 global $wpdb; 45 $click_count_tbl = "{$wpdb->prefix}cloaker_clicks_count"; 46 //drop click_count table 47 $sql = "DROP TABLE IF EXISTS {$click_count_tbl}"; 48 $wpdb->query($sql); 49 } 50 update_option( 'wp_cloaker_version', '1.0.5'); 42 51 } 43 52 //return wp_cloaker_clicks_table columns … … 57 66 } 58 67 59 // create wp_cloaker_clicks_count_table60 public function wp_cloaker_create_clicks_count_table(){61 global $wpdb;62 global $charset_collate;63 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');64 $this->wp_cloaker_register_clicks_table();65 $create_table_sql = "CREATE TABLE IF NOT EXISTS {$wpdb->wp_cloaker_clicks_count_table}(66 count_id bigint(20) unsigned NOT NULL auto_increment,67 link_id bigint(20) unsigned NOT NULL default '0',68 cat_id bigint(20) unsigned NULL default '0',69 counter bigint(20) NOT NULL default '0',70 PRIMARY KEY (count_id),71 KEY link (link_id)72 ) $charset_collate";73 dbDelta($create_table_sql);74 }75 //return wp_cloaker_clicks_count_table columns76 public function wp_cloaker_clicks_count_table_columns(){77 return array(78 'count_id'=> '%d',79 'link_id'=> '%d',80 'cat_id'=> '%d',81 'counter'=>'%d'82 );83 }84 68 /* 85 69 * insert click data to the database … … 104 88 $wpdb->insert_id; 105 89 } 106 /* 107 * insert or update click count data to the database 108 *@param $data array An array of key => value pairs to be inserted 109 *@return int The ID of the created click count row. Or WP_Error or false on failure. 110 */ 111 public function wp_cloaker_click_count( $link_id,$cat_id){ 112 global $wpdb; 113 114 //link ID must be positive integer 115 $link_id = absint($link_id); 116 if( empty($link_id) ) 117 return false; 118 $last_count_sql = "SELECT counter FROM {$wpdb->wp_cloaker_clicks_count_table} 119 WHERE link_id=$link_id"; 120 $last_count = $wpdb->get_var($last_count_sql); 121 if($last_count){ 122 $new_count = (int)$last_count+1; 123 124 $data = array('counter'=>$new_count); 125 if ( false === $wpdb->update($wpdb->wp_cloaker_clicks_count_table, $data, array('link_id'=>$link_id)) ) { 126 return false; 127 } 128 129 return true; 130 }else{ 131 $data = array( 132 'link_id'=>$link_id, 133 'cat_id'=>$cat_id, 134 'counter'=>1 135 ); 136 //insert data into database 137 $wpdb->insert($wpdb->wp_cloaker_clicks_count_table, $data); 138 return $wpdb->insert_id; 139 } 140 } 90 141 91 /* 142 92 * get GEO information from visitor IP address … … 206 156 public function getClickCountByPostID($ID){ 207 157 global $wpdb; 208 $sql = "SELECT count er FROM {$wpdb->wp_cloaker_clicks_count_table} where link_id=$ID";158 $sql = "SELECT count(1) FROM {$wpdb->wp_cloaker_clicks_table} where link_id=$ID"; 209 159 return $wpdb->get_var($sql); 210 160 } … … 215 165 public function getClickCountByCatID($ID){ 216 166 global $wpdb; 217 $sql = "SELECT SUM(counter) as total FROM {$wpdb->wp_cloaker_clicks_count_table} where cat_id=$ID GROUP BY cat_id"; 167 // get cat posts ids 168 $post_ids = get_posts(array( 169 'post_type' => 'wp_cloaker_link', 170 'numberposts' => -1, // get all posts. 171 'tax_query' => array( 172 array( 173 'taxonomy' => 'wp_cloaker_link_category', 174 'field' => 'id', 175 'terms' => $ID, 176 ), 177 ), 178 'fields' => 'ids', // Only get post IDs 179 )); 180 $ids = implode(',',$post_ids); 181 $sql = "SELECT COUNT(1) as total FROM {$wpdb->wp_cloaker_clicks_table} where link_id IN ($ids)"; 218 182 $sum = $wpdb->get_var($sql); 219 183 return $sum; … … 235 199 public function getClicksDetailsTotalBYID($ID){ 236 200 global $wpdb; 237 $sql = "SELECT count( *) FROM {$wpdb->wp_cloaker_clicks_table} where link_id=$ID";201 $sql = "SELECT count(1) FROM {$wpdb->wp_cloaker_clicks_table} where link_id=$ID"; 238 202 $result = $wpdb->get_var($sql); 239 203 return $result; -
wp-cloaker/trunk/classes/class-wp-cloaker.php
r1374737 r1379030 23 23 //hook the single post template 24 24 add_filter('single_template', array($this,'wp_cloaker_link_template')); 25 26 add_option( 'wp_cloaker_version', '1.0.4'); 25 27 26 } 28 27 -
wp-cloaker/trunk/uninstall.php
r1203774 r1379030 9 9 $wpdb->wp_cloaker_clicks_count_table = "{$wpdb->prefix}cloaker_clicks_count"; 10 10 //drop plugin tables 11 $sql = "DROP TABLE IF EXISTS $wpdb->wp_cloaker_clicks_table ,$wpdb->wp_cloaker_clicks_count_table";11 $sql = "DROP TABLE IF EXISTS $wpdb->wp_cloaker_clicks_table"; 12 12 $wpdb->query($sql); 13 13 //delete all posts of wp_cloaker_link post type … … 20 20 $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy=%s",$tax ) ); 21 21 22 // Delete Terms22 // Delete Terms 23 23 foreach ( $terms as $term ) { 24 24 $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) ); … … 32 32 33 33 // delete plugin options 34 delete_option( 'wp_cloaker_version' ); 34 35 delete_option( 'wp_cloaker_link_prefix' ); 35 36 delete_option( 'wp_cloaker_link_redirection' ); -
wp-cloaker/trunk/wp-cloaker.php
r1374737 r1379030 4 4 plugin URI:http://www.wwgate.net 5 5 Description: WP Cloaker gives you the ability to shorten your affiliate ugly links and keep track of how many clicks on each link. 6 Version:1.0. 46 Version:1.0.5 7 7 Author: Fadi Ismail 8 8 Author URI: http://www.wwgate.net … … 11 11 define('wp_cloaker_url', plugins_url('',__FILE__) ); 12 12 define('wp_cloaker_path', WP_PLUGIN_DIR.DIRECTORY_SEPARATOR.'wp-cloaker'.DIRECTORY_SEPARATOR ); 13 define('wp_cloaker_version', '1.0. 4' );13 define('wp_cloaker_version', '1.0.5' ); 14 14 15 15 // if the file is called directly, abort … … 27 27 $wp_cloaker_admin = new WP_Cloaker_Admin(); 28 28 29 //register_uninstall_hook(__FILE__, 'wp_cloaker_uninstall');30 29 register_activation_hook(__FILE__,array(&$wp_cloaker_clicks,'wp_cloaker_create_clicks_table')); 31 register_activation_hook(__FILE__,array(&$wp_cloaker_clicks,'wp_cloaker_create_clicks_count_table'));30 32 31 } 33 32 wp_Cloaker_Start();
Note: See TracChangeset
for help on using the changeset viewer.