| 1 |
<?php |
| 2 |
/** |
| 3 |
* Charitable Connect callback endpoint. |
| 4 |
* |
| 5 |
* Called by upgrade.wpcharitable.com to activate or install Pro. This file |
| 6 |
* loads WordPress and defines CHARITABLE_CONNECT_CALLBACK so the main plugin |
| 7 |
* can run the actual callback on init at priority -9999, before any redirect |
| 8 |
* (e.g. to login) runs. That way the upgrade server's request (no cookies) |
| 9 |
* still gets JSON instead of the login page. |
| 10 |
* |
| 11 |
* @package Charitable |
| 12 |
* @since 1.8.9.6 |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'CHARITABLE_CONNECT_CALLBACK' ) ) { |
| 16 |
define( 'CHARITABLE_CONNECT_CALLBACK', true ); |
| 17 |
} |
| 18 |
|
| 19 |
$wp_root = dirname( dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ) ); |
| 20 |
if ( ! file_exists( $wp_root . '/wp-load.php' ) ) { |
| 21 |
header( 'Content-Type: application/json' ); |
| 22 |
echo json_encode( array( 'success' => false, 'data' => array( 'message' => 'WordPress not found.' ) ) ); |
| 23 |
exit; |
| 24 |
} |
| 25 |
require_once $wp_root . '/wp-load.php'; |
| 26 |
|
| 27 |
// If Charitable ran the callback on init -9999, execution already exited. Otherwise fallback. |
| 28 |
if ( ! function_exists( 'charitable' ) || ! class_exists( 'Charitable_Admin_Connect' ) ) { |
| 29 |
header( 'Content-Type: application/json' ); |
| 30 |
wp_send_json( array( 'success' => false, 'data' => array( 'message' => 'Charitable not loaded.' ) ) ); |
| 31 |
} |
| 32 |
Charitable_Admin_Connect::get_instance()->process(); |
| 33 |
|