|
Server : LiteSpeed System : Linux premium92.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 User : rbnsfqys ( 805) PHP Version : 8.1.33 Disable Function : NONE Directory : /home/rbnsfqys/bettermart.online/wp-content/plugins/surerank/inc/functions/ |
<?php
/**
* Requests class.
*
* Handles HTTP requests for SEO analysis.
*
* @package SureRank\Inc\Analyzer
*/
namespace SureRank\Inc\Functions;
use SureRank\Inc\Traits\Get_Instance;
use WP_Error;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Class Requests
*
* Handles HTTP requests for SEO analysis.
*/
class Requests {
use Get_Instance;
/**
* Get the status code of a URL.
*
* @param string $url The URL to check. It will behave like wp_safe_remote_head.
* @param array<string, mixed> $args The arguments of the request.
* @return array<string, mixed>|WP_Error
*/
public static function head( $url, $args = [] ) {
return wp_safe_remote_head(
$url,
array_merge(
[
'timeout' => 10, // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout
'redirection' => 0,
],
$args
)
);
}
/**
* Get the body of a URL. It will behave like wp_safe_remote_get.
*
* @param string $url The URL to get the body of.
* @param array<string, mixed> $args The arguments of the request.
* @return array<string, mixed>|WP_Error
*/
public static function get( $url, $args = [] ) {
return wp_safe_remote_get(
$url,
$args
);
}
/**
* Post to a URL. It will behave like wp_safe_remote_post.
*
* @param string $url The URL to post to.
* @param array<string, mixed> $args The arguments of the post.
* @return array<string, mixed>|WP_Error
*/
public static function post( $url, $args ) {
return wp_safe_remote_post(
$url,
$args
);
}
/**
* Request to a URL. It will behave like wp_safe_remote_request.
*
* @param string $url The URL to request to.
* @param array<string, mixed> $args The arguments of the request.
* @return array<string, mixed>|WP_Error
*/
public static function request( $url, $args ) {
return wp_safe_remote_request(
$url,
$args
);
}
}