$72 GRAYBYTE WORDPRESS FILE MANAGER $80

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.43.35 | ADMIN IP 216.73.216.180
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : mail

/home/bravrvjk/hpgt.org/wp-content/plugins/elementor/modules/components/

HOME
Current File : /home/bravrvjk/hpgt.org/wp-content/plugins/elementor/modules/components//component-lock-manager.php
<?php
namespace Elementor\Modules\Components;

use Elementor\Modules\Components\Documents\Component as Component_Document;
use Elementor\Modules\Components\Document_Lock_Manager;

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

class Component_Lock_Manager extends Document_Lock_Manager {
	const ONE_HOUR = 60 * 60;
	private static $instance = null;
	public function __construct() {
		parent::__construct( self::ONE_HOUR );
	}

	public static function get_instance() {
		if ( null === self::$instance ) {
			self::$instance = new self();
		}
		return self::$instance;
	}

	public function register_hooks() {
		add_filter( 'heartbeat_received', [ $this, 'heartbeat_received' ], 10, 2 );
	}

	public function heartbeat_received( $response, $data ) {
		if ( ! isset( $data['elementor_post_lock']['post_ID'] ) ) {
			return $response;
		}

		$post_id = $data['elementor_post_lock']['post_ID'];

		if ( ! $this->is_component_post( $post_id ) ) {
			return $response;
		}

		$lock_data = $this->get_lock_data( $post_id );
		$user_id = get_current_user_id();
		if ( $user_id === (int) $lock_data['locked_by'] ) {
			$this->extend_lock( $post_id );
		}

		return $response;
	}


	/**
	 * Unlock a component.
	 *
	 * @param int $post_id The component ID to unlock
	 * @return bool True if unlock was successful, false otherwise
	 * @throws \Exception If post is not a component type.
	 */
	public function unlock( $post_id ) {
		if ( ! $this->is_component_post( $post_id ) ) {
				throw new \Exception( 'Post is not a component type' );
		}

		$lock_data = $this->get_lock_data( $post_id );
		$current_user_id = get_current_user_id();
		if ( $lock_data['locked_by'] && (int) $lock_data['locked_by'] !== (int) $current_user_id ) {
			return false;
		}
		return parent::unlock( $post_id );
	}

	/**
	 * Lock a component.
	 *
	 * @param int $post_id The component ID to lock
	 * @return bool|null True if lock was successful, null if locked by another user, false otherwise
	 * @throws \Exception If post is not a component type.
	 */
	public function lock( $post_id ) {
		if ( ! $this->is_component_post( $post_id ) ) {
			throw new \Exception( 'Post is not a component type' );
		}

		$lock_data = $this->get_lock_data( $post_id );
		$is_expired = $this->is_lock_expired( $post_id );

		if ( $is_expired ) {
			parent::unlock( $post_id );
		} elseif ( $lock_data['locked_by'] ) {
			return null;
		}

		return parent::lock( $post_id );
	}

	/**
	 * Get lock data for a component.
	 *
	 * @param int $post_id The component ID
	 * @return array Lock data with 'locked_by' (int|null), 'locked_at' (int|null)
	 * @throws \Exception If post is not a component type.
	 */
	public function get_lock_data( $post_id ) {
		if ( ! $this->is_component_post( $post_id ) ) {
			throw new \Exception( 'Post is not a component type' );
		}

		return parent::get_lock_data( $post_id );
	}

	/**
	 * Extend the lock for a component.
	 *
	 * @param int $post_id The component ID
	 * @return bool|null True if extended successfully, null if not locked or locked by another user
	 * @throws \Exception If post is not a component type.
	 */
	public function extend_lock( $post_id ) {
		if ( ! $this->is_component_post( $post_id ) ) {
			throw new \Exception( 'Post is not a component type' );
		}

		$lock_data = $this->get_lock_data( $post_id );
		if ( ! $lock_data['locked_by'] ) {
			return null;
		}

		$current_user_id = get_current_user_id();
		if ( (int) $lock_data['locked_by'] !== (int) $current_user_id ) {
			return null;
		}

		return parent::extend_lock( $post_id );
	}

	private function is_component_post( $post_id ) {
		return get_post_type( $post_id ) === Component_Document::TYPE;
	}
}


Current_dir [ WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
documents
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
overridable-props
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
prop-types
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
styles
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
transformers
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
utils
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
widgets
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
circular-dependency-validator.php
4.516 KB
2 Feb 2026 2.52 PM
bravrvjk / bravrvjk
0644
component-lock-manager.php
3.609 KB
22 Dec 2025 5.25 PM
bravrvjk / bravrvjk
0644
components-access-controller.php
1.39 KB
30 Mar 2026 1.49 PM
bravrvjk / bravrvjk
0644
components-repository.php
5.762 KB
2 Feb 2026 2.52 PM
bravrvjk / bravrvjk
0644
components-rest-api.php
21.413 KB
1 Apr 2026 5.39 PM
bravrvjk / bravrvjk
0644
document-lock-manager.php
4.497 KB
22 Dec 2025 5.25 PM
bravrvjk / bravrvjk
0644
module.php
5.864 KB
1 Apr 2026 5.39 PM
bravrvjk / bravrvjk
0644
non-atomic-widget-validator.php
2.59 KB
2 Feb 2026 2.52 PM
bravrvjk / bravrvjk
0644
overridable-schema-extender.php
0.905 KB
2 Feb 2026 2.52 PM
bravrvjk / bravrvjk
0644
save-components-validator.php
2.35 KB
2 Feb 2026 2.52 PM
bravrvjk / bravrvjk
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF