Skip to content

Commit

Permalink
Merge pull request #11 from newfold-labs/yith-events
Browse files Browse the repository at this point in the history
Yith events
  • Loading branch information
wpscholar authored Dec 13, 2022
2 parents f4f8bf4 + 63dcc27 commit 4615138
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/EventManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class EventManager {
'\\NewfoldLabs\\WP\\Module\\Data\\Listeners\\BluehostPlugin',
'\\NewfoldLabs\\WP\\Module\\Data\\Listeners\\SiteHealth',
'\\NewfoldLabs\\WP\\Module\\Data\\Listeners\\Theme',
'\\NewfoldLabs\\WP\\Module\\Data\\Listeners\\Yith',
);

/**
Expand Down
40 changes: 40 additions & 0 deletions src/Listeners/Yith.php
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;
}
}

0 comments on commit 4615138

Please sign in to comment.