Changeset 412894
- Timestamp:
- 07/21/2011 02:25:02 AM (14 years ago)
- Location:
- wordpress-amazon-associate/trunk
- Files:
-
- 5 edited
-
AmazonProduct.php (modified) (1 diff)
-
WPAA.php (modified) (8 diffs)
-
WPAA/CacheHandler.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
wordpress_amazon_associate.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wordpress-amazon-associate/trunk/AmazonProduct.php
r410533 r412894 171 171 // get Locale 172 172 $locale = $wpaa->getGeoLocale( $options['locale'] ); 173 //validate Product Exists 174 if( ! $wpaa->getCacheHandler()->productExists( $options['asin'], $locale ) ) { 175 $locale = $wpaa->getLocale(); 176 } 177 173 178 // Append service url 174 179 $outputStr .= WPAA_URIHandler::getRemoteContentURI( $locale ) . '?'; -
wordpress-amazon-associate/trunk/WPAA.php
r410863 r412894 205 205 * @var String 206 206 */ 207 protected $version = '1.7. 1';207 protected $version = '1.7.2'; 208 208 209 209 /** … … 211 211 * @var String 212 212 */ 213 protected $last_updated = '07- 16-2011';213 protected $last_updated = '07-20-2011'; 214 214 215 215 /** … … 281 281 add_filter('comment_text', array(&$this,'filter_amazon_associate_tag'), 25); 282 282 } 283 // add amazon rel="nofilter" filter 284 add_filter('the_content', array(&$this, 'filter_rel_nofollow'), 20 ); 283 285 // insert product preview code if enabled 284 286 if( $this->options['ProductPreview'] === true ) { … … 305 307 } 306 308 echo $content; 309 } 310 311 /** 312 * Filter content and add rel="nofollow" to Amazon Links 313 * 314 * @param string $content 315 * @return string 316 */ 317 public function filter_rel_nofollow($content) { 318 preg_match_all('~<a.*>~isU',$content,$matches); 319 for ( $i = 0; $i <= sizeof($matches[0]) - 1; $i++){ 320 if ( !preg_match( '~nofollow~is', $matches[0][$i]) 321 && (preg_match('~http://www.amazon.~', $matches[0][$i]) )){ 322 $result = trim($matches[0][$i],">"); 323 $result .= ' rel="nofollow">'; 324 $content = str_replace($matches[0][$i], $result, $content); 325 } 326 } 327 return $content; 307 328 } 308 329 … … 320 341 foreach ($filtered_matches as $key => $match) { 321 342 $orig_str = $match; 322 $new_str = $orig_str;323 if( $this->modules[self::MODULE_IP2NATION]->isInstalled() && $this->options['LocaleByGeoIP'] ) {324 $new_str = $this->localize_static_tag( $new_str );325 }343 $new_str = $orig_str; 344 if( $this->modules[self::MODULE_IP2NATION]->isInstalled() && $this->options['LocaleByGeoIP'] ) { 345 $new_str = $this->localize_static_tag( $new_str ); 346 } 326 347 $new_str = $this->replace_associate_tag( $new_str ); 327 348 if( $orig_str != $new_str ) { … … 605 626 if( is_null( $locale ) || empty( $locale ) ) { 606 627 // Admin Localization 607 if( function_exists('wp_get_current_user') && function_exists('current_user_can') ) {608 if ( current_user_can('manage_options') ) {609 if( $this->options['CVEnabled'] && $this->options['CVLocale'] != '' ) {610 return $this->options['CVLocale'];611 }612 }613 }628 if( function_exists('wp_get_current_user') && function_exists('current_user_can') ) { 629 if ( current_user_can('manage_options') ) { 630 if( $this->options['CVEnabled'] && $this->options['CVLocale'] != '' ) { 631 return $this->options['CVLocale']; 632 } 633 } 634 } 614 635 // Get Geo Locale if enabled 615 636 if( $this->modules[self::MODULE_IP2NATION]->isInstalled() && $this->options['LocaleByGeoIP'] ) { … … 867 888 } 868 889 869 // migration of Widgets Enabled :: Version < 2.0.0 Upgrade890 // migration of Widgets Enabled :: Version < 1.7.0 Upgrade 870 891 if( isset( $this->options['AmazonCarouselWidget'])) { 871 892 $this->modules[self::MODULE_AMAZON_WIDGETS]->updateSettings( $this->options ); … … 879 900 } 880 901 881 // update AWSValid with current settings :: Version < 2.0.0 Upgrade902 // update AWSValid with current settings :: Version < 1.7.0 Upgrade 882 903 if( is_null( $this->options['AWSValid'] ) ) { 883 904 $this->options['AWSValid'] = $this->validateCredentials(); -
wordpress-amazon-associate/trunk/WPAA/CacheHandler.php
r410533 r412894 149 149 150 150 /** 151 * check if Amazon Product exists in given locale 152 * @global WPAA $wpaa 153 * @global WPDB $wpdb 154 * @param string $id 155 * @param string $locale 156 * @param string $type 157 * @param string $responseGroup 158 */ 159 public function productExists( $id, $locale=null, $type="ASIN", $responseGroup=null ) { 160 global $wpaa; 161 global $wpdb; 162 $locale = $wpaa->getGeoLocale( $locale ); 163 164 if( $this->_enabled ) { // cache is enabled 165 $cache_index = $locale . $id . $type . $responseGroup; 166 if( isset( $this->_cache[$cache_index] ) ) { // check php cache 167 $result = $this->_cache[$cache_index]; 168 return $result->isSuccess(); 169 } else { 170 //lookup product in db cache 171 $sql = $wpdb->prepare( "Select data, updated_ts FROM `$this->_table` WHERE id='%s' AND locale='%s' AND type='%s' AND response_group='%s';", $id, $locale, $type, $responseGroup ); 172 $result = $wpdb->get_row( $sql ); 173 174 //product not in cache 175 if( is_null( $result ) ) { 176 $result = $this->getProductByAPI($id, $locale, $type, $responseGroup); 177 //cache result in db 178 $sql = $wpdb->insert( $this->_table, array( 'id' => $id, 'locale' => $locale, 'type' => $type, 'response_group' => $responseGroup, 'data' => serialize( $result ), 'updated_ts' => date( 'Y-m-d', time() ) ) ); 179 // cache result in php 180 $this->_cache[$cache_index] = $result; 181 return $result->isSuccess(); 182 } else { 183 184 // cache has expired 185 if( $this->_expire > 0 && strtotime ( '+' . $this->_expire . ' day' , strtotime( $result->updated_ts ) ) < time() ) { 186 $result = $this->getProductByAPI($id, $locale, $type, $responseGroup); 187 //cache result in db 188 $sql = $wpdb->update( $this->_table, array( 'data' => serialize( $result ), 'updated_ts' => date( 'Y-m-d', time() ) ), array( 'id' => $id, 'locale' => $locale, 'type' => $type, 'response_group' => $responseGroup ) ); 189 // cache result in php 190 $this->_cache[$cache_index] = $result; 191 // if product does not exist for locale then get product from default locale 192 return $result->isSuccess(); 193 } else { 194 //unserialize db cache 195 $result = unserialize($result->data); 196 // cache result in php 197 $this->_cache[$cache_index] = $result; 198 return $result->isSuccess(); 199 } 200 } 201 } 202 } else { // cache is disabled 203 $result = $this->getProductByAPI($id, $locale, $type, $responseGroup); 204 // if product does not exist for locale then get product from default locale 205 return $result->isSuccess(); 206 } 207 } 208 209 /** 151 210 * get Product from Amazon Product API 152 211 * @global WPAA $wpaa -
wordpress-amazon-associate/trunk/readme.txt
r410533 r412894 45 45 1. **Amazon Product Linking** 46 46 47 1. **Amazon Product Link Filtering**47 1. **Amazon Product Link Associate Tag filtering & update with rel="nofollow"** 48 48 49 49 1. **Amazon Product Preview** … … 187 187 188 188 The full project changelogs can be found at [http://labs.mdbitz.com/wordpress/wordpress-amazon-associate-plugin/changelog](http://labs.mdbitz.com/wordpress/wordpress-amazon-associate-plugin/changelog/?utm_source=wordpress&utm_medium=plugin-readme&utm_campaign=plugin) 189 190 = 1.7.2 - 07/20/2011 = 191 * Added check to Enhanced add to confirm product exists for Geo-Localization if not defaults to primary locale 192 * Static Amazon Product links updated with rel="nofollow" automatically 193 194 = 1.7.1 - 07/16/2011 = 195 * Content Viewer Module - Update to check if wp_get_current_user exists to resolve WordPress issue 189 196 190 197 = 1.7.0 - 07/15/2011 = -
wordpress-amazon-associate/trunk/wordpress_amazon_associate.php
r410863 r412894 5 5 Description: Quickly and eaily monetize your webiste through the integration of Amazon products and widgets tagged with your associate id. 6 6 Author: MDBitz - Matthew John Denton 7 Version: 1.7. 17 Version: 1.7.2 8 8 Requires at least: 3.0.0 9 9 Author URI: http://labs.mdbitz.com … … 44 44 require_once plugin_dir_path(__FILE__) . 'WPAA.php'; 45 45 spl_autoload_register(array('WPAA', 'autoload')); 46 $wpaa = new WPAA(); 46 $wpaa = new WPAA( ); 47 48 // deactivation 49 register_deactivation_hook( __FILE__, 'wpaa_deactivate'); 50 51 /** 52 * send site uninstall information 53 */ 54 function wpaa_deactivate() { 55 if( function_exists('curl_init') ) { 56 $handle = curl_init('http://mdbitz.com/installs.php?app=WPAA&uninstall=true&site=' . site_url() ); 57 if (false !== $handle) { 58 curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE); 59 curl_setopt($handle, CURLOPT_NOBODY, true); 60 $response = curl_exec($handle); 61 curl_close($handle); 62 } 63 } 64 } 65 66 // deactivation 67 register_activation_hook( __FILE__, 'wpaa_activate'); 68 69 /** 70 * send site activation information 71 */ 72 function wpaa_activate() { 73 if( function_exists('curl_init') ) { 74 $handle = curl_init('http://mdbitz.com/installs.php?app=WPAA&activate=true&site=' . site_url() ); 75 if (false !== $handle) { 76 curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE); 77 curl_setopt($handle, CURLOPT_NOBODY, true); 78 $response = curl_exec($handle); 79 curl_close($handle); 80 } 81 } 82 }
Note: See TracChangeset
for help on using the changeset viewer.