Last active
August 6, 2021 14:20
-
-
Save michaeluno/d8dbd34770cf6b8ad63d0d6c30d925f3 to your computer and use it in GitHub Desktop.
An Amazon Auto Links extension plugin of WordPress that drops products if they don't have price information.
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 - Drop Products without Price | |
* Plugin URI: https://en.michaeluno.jp/amazon-auto-links | |
* Description: Drops products without a price | |
* Author: Michael Uno (miunosoft) | |
* Author URI: https://michaeluno.jp | |
* Version: 1.0.0 | |
*/ | |
/** | |
* The loader. | |
*/ | |
class AmazonAutoLinks_DropProductsWithoutPrice { | |
/** | |
* Sets up properties and hooks. | |
*/ | |
public function __construct() { | |
add_filter( 'aal_filter_unit_each_product_with_database_row', array( $this, 'replyToFilterProduct' ), 200 ); | |
} | |
/** | |
* @param array $aProduct | |
* @return array | |
* @callback add_filter() aal_filter_unit_each_product_with_database_row | |
*/ | |
public function replyToFilterProduct( $aProduct ) { | |
if ( empty( $aProduct ) ) { | |
return $aProduct; | |
} | |
if ( empty( $aProduct[ 'formatted_price' ] ) ) { | |
return array(); | |
} | |
return $aProduct; | |
} | |
} | |
new AmazonAutoLinks_DropProductsWithoutPrice; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment