HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wpmuhibbah_err/wp-content/plugins/defender-security/framework/helper/class-route.php
<?php
/**
 * Helper to enqueue ajax route, also generate the nonce's.
 *
 * @package Calotes\Helper
 */

namespace Calotes\Helper;

/**
 * Helper to enqueue ajax route, also generate the nonce's.
 */
class Route {

	/**
	 * Array to store registered routes.
	 *
	 * @var array
	 */
	protected static $routes = array();

	/**
	 * Array to store nonce's for registered routes.
	 *
	 * @var array
	 */
	protected static $nonces = array();

	/**
	 * Registers a new route for handling AJAX requests.
	 *
	 * @param  mixed $name  The name of the route.
	 * @param  mixed $category  The category of the route.
	 * @param  mixed $route  The route to be registered.
	 * @param  mixed $callback  The callback function to handle the request.
	 * @param  bool  $nopriv  Whether the route should be accessible without authentication.
	 */
	public static function register_route( $name, $category, $route, $callback, $nopriv = false ) {
		$namespace = self::get_namespace( $category );
		$route     = $namespace . '/' . $route;
		add_action( 'wp_ajax_' . $route, $callback );
		if ( true === $nopriv ) {
			add_action( 'wp_ajax_nopriv_' . $route, $callback );
		}
		if ( ! isset( self::$routes[ $category ] ) ) {
			self::$routes[ $category ] = array();
			self::$nonces[ $category ] = array();
		}
		self::$routes[ $category ][ $name ] = $route;
		self::$nonces[ $category ][ $name ] = wp_create_nonce( $name . $category );
	}

	/**
	 * Retrieves the exported routes and nonce's for the specified categories.
	 *
	 * @param  mixed $categories  The categories for which to export routes and nonce's.
	 *
	 * @return array The exported routes and nonce's.
	 */
	public static function export_routes( $categories ) {
		$routes = self::$routes[ $categories ] ?? array();
		$nonces = self::$nonces[ $categories ] ?? array();

		return array( $routes, $nonces );
	}

	/**
	 * Retrieves the namespace for a given module.
	 *
	 * @param  mixed $module  The module for which to retrieve the namespace.
	 *
	 * @return string The namespace for the specified module.
	 */
	public static function get_namespace( $module ) {
		return 'wp-defender/v1/' . $module;
	}
}