Server IP : 104.21.14.48 / Your IP : 3.147.13.252 [ Web Server : Apache System : Linux b70eb322-3aee-0c53-7c82-0db91281f2c6.secureserver.net 6.1.90-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 2 12:09:22 EDT 2024 x86_64 User : root ( 0) PHP Version : 8.0.30.2 Disable Function : NONE Domains : 0 Domains MySQL : ON | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/wp-content/mu-plugins/vendor/wpex/godaddy-launch/includes/ |
Upload File : |
<?php /** * The ServiceProvider class. * * @package GoDaddy */ namespace GoDaddy\WordPress\Plugins\Launch; /** * The ServiceProvider class. */ abstract class ServiceProvider { /** * The application instance. * * @var \GoDaddy\WordPress\Plugins\Launch\Application; */ protected $app; /** * Create a new service provider instance. * * @param \GoDaddy\WordPress\Plugins\Launch\Application $app The Application. */ public function __construct( $app ) { $this->app = $app; } /** * Register any application services. */ public function register() {} /** * Take in raw json data from API and format into usable WP response here. * * Example raw response * {{"headers":[],"body":"","response":{"code":true,"message":"sample",},"cookies":[],"http_response":null}} * * @param Array $remote_request The raw remote request data. * @return \WP_Error|\WP_Rest_Response Error if invalid or typical REST response otherwise. */ protected function format_remote_post_response( $remote_request ) { if ( ! is_array( $remote_request ) || is_wp_error( $remote_request ) ) { return rest_ensure_response( $remote_request ); } // Retrieve information. $response_code = wp_remote_retrieve_response_code( $remote_request ); $response_message = wp_remote_retrieve_response_message( $remote_request ); $response_body = wp_remote_retrieve_body( $remote_request ); return new \WP_REST_Response( array( 'status' => $response_code, 'response' => $response_message, 'body_response' => json_decode( $response_body ), ), $response_code ); } /** * Function takes in $url and $body variables and performs wp_remote_post call * to NUX api and return the response. * * @param String $url String representing the external URI of the NUX API. * @param Array $body Contains the content sent to NUX API. * @return Array Raw response object from NUX API. */ protected function perform_remote_api_post( $url, $body ) { return wp_remote_post( $url, array( 'headers' => array( 'Content-Type' => 'application/json' ), 'body' => wp_json_encode( $body ), ) ); } }