HEX
Server: Apache/2
System: Linux bq-e705.pointdnshere.com 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User: wellmix (1103)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/wellmix/public_html/wp-content/plugins/pymntpl-paypal-woocommerce/src/RestApi.php
<?php

namespace PaymentPlugins\WooCommerce\PPCP;

use PaymentPlugins\WooCommerce\PPCP\Rest\RestController;

class RestApi {

	private $controller;

	public function __construct( RestController $controller ) {
		$this->controller = $controller;
		add_action( 'rest_api_init', [ $this->controller, 'register_rest_routes' ] );
		add_action( 'wp_ajax_wc_ppcp_admin_request', array( $this, 'process_admin_request' ) );
	}

	public static function get_admin_endpoint( $path ) {
		$url = admin_url( 'admin-ajax.php' );

		return add_query_arg( array( 'action' => 'wc_ppcp_admin_request', 'path' => '/' . trim( $path, '/' ) ), $url );
	}

	public function process_admin_request() {
		// phpcs:disable WordPress.Security.NonceVerification.Recommended
		if ( isset( $_GET['path'] ) ) {
			global $wp;
			$wp->set_query_var( 'rest_route', sanitize_text_field( wp_unslash( $_GET['path'] ) ) );
			rest_api_loaded();
		}
	}

}