1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113:
<?php
class Inbound_Pro_Oauth_Engine {
static $settings_values;
public static function init() {
self::add_hooks();
}
public static function add_hooks() {
add_action( 'admin_init' , array( __CLASS__ , 'inline_js' ) );
add_action( 'admin_init' , array( __CLASS__ , 'request_access_token' ) );
add_action( 'admin_init' , array( __CLASS__ , 'save_access_token' ) );
add_action( 'admin_init' , array( __CLASS__ , 'display_success' ) );
add_action( 'wp_ajax_revoke_oauth_tokens' , array( __CLASS__ , 'revoke_oauth_tokens' ) );
}
public static function request_access_token() {
if ( !isset($_REQUEST['action']) || $_REQUEST['action'] != 'request_access_token' ) {
return;
}
do_action('inbound_oauth/request_access_token');
exit;
}
public static function save_access_token() {
if ( !isset($_REQUEST['action']) || $_REQUEST['action'] != 'save_access_token' ) {
return;
}
do_action('inbound_oauth/save_access_token');
exit;
}
public static function display_success() {
if ( !isset($_REQUEST['action']) || $_REQUEST['action'] != 'display_success' ) {
return;
}
do_action('inbound_oauth/display_success');
exit;
}
public static function revoke_oauth_tokens() {
if ( !isset($_REQUEST['action']) || $_REQUEST['action'] != 'revoke_oauth_tokens' ) {
return;
}
parse_str($_POST['input'] , $data );
$settings = Inbound_Options_API::get_option( 'inbound-pro' , 'settings' , array() );
unset($settings[ $data['fieldGroup'] ]['oauth']);
Inbound_Options_API::update_option( 'inbound-pro' , 'settings' , $settings );
do_action('inbound_oauth/revoke_oauth_tokens');
}
public static function inline_js() {
}
}
Inbound_Pro_Oauth_Engine::init();