| @@ -258,8 +258,14 @@ | ||
| 258 | 258 | 'message' => '', |
| 259 | 259 | 'prompt' => false, |
| 260 | 260 | 'callback' => array( $this, 'verify_logs_table' ), |
| 261 | 261 | ), |
| 262 | + 'sync_paypal_license_to_middleware' => array( | |
| 263 | + 'version' => '1.8.11.2', | |
| 264 | + 'message' => '', | |
| 265 | + 'prompt' => false, | |
| 266 | + 'callback' => array( $this, 'sync_paypal_license_to_middleware' ), | |
| 267 | + ), | |
| 262 | 268 | ); |
| 263 | 269 | } |
| 264 | 270 | |
| 265 | 271 | /** |
| @@ -1591,8 +1597,43 @@ | ||
| 1591 | 1597 | add_option( 'charitable_paypal_user_tier', $tier, '', 'yes' ); |
| 1592 | 1598 | } |
| 1593 | 1599 | |
| 1594 | 1600 | $this->finish_upgrade( 'detect_paypal_user_tier' ); |
| 1601 | + | |
| 1602 | + return true; | |
| 1603 | + } | |
| 1604 | + | |
| 1605 | + /** | |
| 1606 | + * One-time push of the Charitable license_key so already-connected | |
| 1607 | + * licensed Lite sites self-heal. Skips finish_upgrade() to avoid a | |
| 1608 | + * redirect on init priority 5. | |
| 1609 | + * | |
| 1610 | + * @since 1.8.11.2 | |
| 1611 | + * | |
| 1612 | + * @return bool | |
| 1613 | + */ | |
| 1614 | + public function sync_paypal_license_to_middleware() { | |
| 1615 | + | |
| 1616 | + if ( ! function_exists( 'charitable_paypal_get_license_key' ) | |
| 1617 | + || ! function_exists( 'charitable_paypal_send_license_to_connected_modes' ) ) { | |
| 1618 | + return true; | |
| 1619 | + } | |
| 1620 | + | |
| 1621 | + $license_key = charitable_paypal_get_license_key(); | |
| 1622 | + if ( '' === $license_key ) { | |
| 1623 | + return true; | |
| 1624 | + } | |
| 1625 | + | |
| 1626 | + $settings = get_option( 'charitable_settings', array() ); | |
| 1627 | + $gw = isset( $settings['gateways_paypal_commerce'] ) && is_array( $settings['gateways_paypal_commerce'] ) | |
| 1628 | + ? $settings['gateways_paypal_commerce'] | |
| 1629 | + : array(); | |
| 1630 | + $has_seller = ! empty( $gw['live_seller_merchant_id'] ) || ! empty( $gw['sandbox_seller_merchant_id'] ); | |
| 1631 | + if ( ! $has_seller ) { | |
| 1632 | + return true; | |
| 1633 | + } | |
| 1634 | + | |
| 1635 | + charitable_paypal_send_license_to_connected_modes( $license_key ); | |
| 1595 | 1636 | |
| 1596 | 1637 | return true; |
| 1597 | 1638 | } |
| 1598 | 1639 | } |