-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from newfold-labs/yith-events
Yith events
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace NewfoldLabs\WP\Module\Data\Listeners; | ||
|
||
/** | ||
* Monitors Yith events | ||
*/ | ||
class Yith extends Listener { | ||
|
||
/** | ||
* Register the hooks for the listener | ||
* | ||
* @return void | ||
*/ | ||
public function register_hooks() { | ||
//Paypal Connection | ||
add_filter( 'pre_update_option_yith_ppwc_merchant_data_production', array( $this, 'paypal_connection' ), 10, 2 ); | ||
} | ||
|
||
/** | ||
* PayPal connected | ||
* | ||
* @param string $new_option New value of the yith_ppwc_merchant_data_production option | ||
* @param string $old_option Old value of the yith_ppwc_merchant_data_production option | ||
* | ||
* @return string The new option value | ||
*/ | ||
public function paypal_connection( $new_option, $old_option ) { | ||
if ( $new_option !== $old_option && ! empty( $new_option ) ) { | ||
$this->push( | ||
'yith_payment_connected', | ||
array( | ||
'provider' => 'paypal' | ||
) | ||
); | ||
} | ||
|
||
return $new_option; | ||
} | ||
} |