HEX
Server: LiteSpeed
System: Linux venus 5.15.0-156-generic #166-Ubuntu SMP Sat Aug 9 00:02:46 UTC 2025 x86_64
User: axxoncom (1007)
PHP: 8.3.19
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/axxoncom/public_html/wp-content/plugins/pro-elements/core/utils/registrar.php
<?php

namespace ElementorPro\Core\Utils;

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

/**
 * Basic items registrar.
 *
 * TODO: Move to Core.
 */
class Registrar {

	/**
	 * @var array
	 */
	private $items;

	/**
	 * Registrar constructor.
	 *
	 * @return void
	 */
	public function __construct() {
		$this->items = [];
	}

	/**
	 * Register a new item.
	 *
	 * @param           $instance - Item instance.
	 * @param string    $id - Optional - For BC - Deprecated.
	 *
	 * @return boolean - Whether the item was registered.
	 */
	public function register( $instance, $id = null ) {
		// TODO: For BC. Remove in the future.
		if ( ! $id ) {
			// Get the ID or default to the class name.
			$id = ( method_exists( $instance, 'get_id' ) ) ? $instance->get_id() : get_class( $instance );
		}

		if ( $this->get( $id ) ) {
			return false;
		}

		$this->items[ $id ] = $instance;

		return true;
	}

	/**
	 * Get an item by ID.
	 *
	 * @param string $id
	 *
	 * @return array|null
	 */
	public function get( $id = null ) {
		if ( ! $id ) {
			return $this->items;
		}

		return isset( $this->items[ $id ] ) ? $this->items[ $id ] : null;
	}
}