handleRequest(); $result['success'] = true; echo json_encode( $result ); } catch ( Exception $exception ) { if ( $exception instanceof bizpanda\includes\gates\exceptions\GateBridgeException || $exception instanceof bizpanda\includes\gates\exceptions\GateException ) { $result = [ 'success' => false, 'code' => $exception->getExceptionCode(), 'error' => $exception->getExceptionVisibleMessage(), 'details' => $exception->getExceptionDetails() ]; } else { $result = [ 'success' => false, 'error' => __('Something weird happened. We will fix it soon. Please try again later.', 'bizpanda'), 'details' => [ 'clarification' => $exception->getMessage() ] ]; } if ( defined('ONP_DEVELOPING_MODE') && ONP_DEVELOPING_MODE ) { $result['trace'] = $exception->getTraceAsString(); } echo json_encode( $result ); } exit; } /** * Returns the handler options. * @param $handlerName string * @return array */ function opanda_get_handler_options( $handlerName ) { switch ( $handlerName ) { case 'facebook': $callbackUrl = !( defined('ONP_DEVELOPING_MODE') && ONP_DEVELOPING_MODE ) ? opanda_local_proxy_url(['opandaHandler' => $handlerName]) : 'https://gate.sociallocker.app/fauth-wp-dev'; return [ 'clientId' => get_option('opanda_facebook_app_id'), 'clientSecret' => get_option('opanda_facebook_secret'), 'callbackUrl' => $callbackUrl ]; case 'twitter': $callbackUrl = !( defined('ONP_DEVELOPING_MODE') && ONP_DEVELOPING_MODE ) ? opanda_local_proxy_url(['opandaHandler' => $handlerName]) : 'https://gate.sociallocker.app/tauth-wp-dev'; $params = [ 'read' => [ 'clientId' => get_option('opanda_twitter_social_app_consumer_key'), 'clientSecret' => get_option('opanda_twitter_social_app_consumer_secret') ], 'write' => [ 'clientId' => get_option('opanda_twitter_signin_app_consumer_key'), 'clientSecret' => get_option('opanda_twitter_signin_app_consumer_secret'), ], 'callbackUrl' => $callbackUrl ]; if ( empty( $params['read']['clientId'] ) ) { $params['read'] = $params['write']; } return $params; case 'google': $callbackUrl = !( defined('ONP_DEVELOPING_MODE') && ONP_DEVELOPING_MODE ) ? opanda_local_proxy_url(['opandaHandler' => $handlerName]) : 'https://gate.sociallocker.app/gauth-wp-dev'; return [ 'clientId' => get_option('opanda_google_client_id'), 'clientSecret' => get_option('opanda_google_client_secret'), 'callbackUrl' => $callbackUrl ]; case 'linkedin': $callbackUrl = !( defined('ONP_DEVELOPING_MODE') && ONP_DEVELOPING_MODE ) ? opanda_local_proxy_url(['opandaHandler' => $handlerName]) : 'https://gate.sociallocker.app/lauth-wp-dev'; return [ 'clientId' => get_option('opanda_linkedin_client_id'), 'clientSecret' => get_option('opanda_linkedin_client_secret'), 'callbackUrl' => $callbackUrl ]; case 'subscription': return array( 'service' => get_option('opanda_subscription_service', 'database') ); case 'signup': return array(); } } /** * Returns the lists available for the current subscription service. * * @since 1.0.0 * @return void */ function opanda_get_subscrtiption_lists() { require OPANDA_BIZPANDA_DIR.'/admin/includes/subscriptions.php'; try { $service = OPanda_SubscriptionServices::getCurrentService(); $lists = $service->getLists(); echo json_encode($lists); } catch (Exception $ex) { echo json_encode( array('error' => 'Unable to get the lists: ' . $ex->getMessage() ) ); } exit; } add_action( 'wp_ajax_opanda_get_subscrtiption_lists', 'opanda_get_subscrtiption_lists' ); /** * Returns the lists available for the current subscription service. * * @since 1.0.0 * @return void */ function opanda_get_custom_fields() { require OPANDA_BIZPANDA_DIR.'/admin/includes/subscriptions.php'; try { $listId = isset( $_POST['opanda_list_id'] ) ? $_POST['opanda_list_id'] : null; $service = OPanda_SubscriptionServices::getCurrentService(); $fields = $service->getCustomFields( $listId ); echo json_encode($fields); } catch (Exception $ex) { echo json_encode( array('error' => $ex->getMessage() ) ); } exit; } add_action( 'wp_ajax_opanda_get_custom_fields', 'opanda_get_custom_fields' );