Created
July 26, 2018 10:33
-
-
Save michaeluno/c4168ea4b894f0dce4d4e5ce0633be65 to your computer and use it in GitHub Desktop.
Converts product links to the Amazon Smile domain, generated by the Amazon Auto Links WordPress plugin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Amazon Auto Links - Product Link to Amazon Smile | |
* Plugin URI: http://en.michaeluno.jp/amazon-auto-links | |
* Description: Converts product links to the Amazon Smile domain | |
* Author URI: http://michaeluno.jp | |
* Version: 0.0.1 | |
* Author: Michael Uno | |
*/ | |
new AmazonAutoLinks_AmazonSmileProductLinks; | |
class AmazonAutoLinks_AmazonSmileProductLinks { | |
public function __construct() { | |
add_filter( 'aal_filter_product_link', array( $this, '_getProductLinkModified' ), 10, 4 ); | |
} | |
public function _getProductLinkModified( $sURL, $sRawURL, $sASIN, $aUnitOptions ) { | |
return str_replace( | |
"://www.amazon.", // search | |
"://smile.amazon.", // replace | |
$sURL // subject | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment