Last active
November 16, 2020 09:12
-
-
Save michaeluno/bd7e4f50070f921c88c4fe2fcff620d6 to your computer and use it in GitHub Desktop.
An Amazon Auto Links, a WordPress plugin, extension plugin that removes a part enclosed in parentheses in price outputs.
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 - Filter Prices | |
* Description: Removes a part enclosed in parentheses in price outputs. | |
* Version: 1.0.0 | |
*/ | |
/** | |
* | |
*/ | |
class AmazonAutoLinks_Customize_RemoveParenthesesInPriceOutputs { | |
/** | |
* Sets up hooks. | |
*/ | |
public function __construct() { | |
add_filter( 'aal_filter_unit_each_product_with_database_row', array( $this, 'getProduct' ), 9999 ); | |
} | |
/** | |
* @param array $aProduct | |
* @return array | |
*/ | |
public function getProduct( $aProduct ) { | |
$aProduct[ 'formatted_price' ] = preg_replace( '/\s?\(.+?\)/', '', $aProduct[ 'formatted_price' ] ); | |
return $aProduct; | |
} | |
} | |
new AmazonAutoLinks_Customize_RemoveParenthesesInPriceOutputs; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment