HEX
Server: LiteSpeed
System: Linux server902.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: deshuvsd (2181)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //proc/thread-self/root/home/deshuvsd/www/wp-content/plugins/surerank/inc/functions/utils.php
<?php
/**
 * Utils.
 *
 * Utils module class for handling utils functions.
 *
 * @package SureRank\Inc\Functions;
 * @since 1.5.0
 */

namespace SureRank\Inc\Functions;

use SureRank\Inc\Traits\Get_Instance;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Utils class
 *
 * Main module class for utils functions.
 */
class Utils {

	use Get_Instance;

	/**
	 * Convert absolute URL to relative path.
	 *
	 * Removes the home URL and trailing slashes from the given URL.
	 *
	 * @param string $url Full URL.
	 * @return string Relative path without leading/trailing slashes.
	 * @since 1.5.0
	 */
	public static function get_relative_url( $url ) {
		$home_url = trailingslashit( home_url() );
		$relative = str_replace( $home_url, '', trailingslashit( $url ) );
		return rtrim( $relative, '/' );
	}
}