<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor heartbeat.
*
* Elementor heartbeat handler class is responsible for initializing Elementor
* heartbeat. The class communicates with WordPress Heartbeat API while working
* with Elementor.
*
* @since 1.0.0
*/
class Heartbeat {
/**
* Heartbeat received.
*
* Locks the Heartbeat response received when editing with Elementor.
*
* Fired by `heartbeat_received` filter.
*
* @since 1.0.0
* @access public
*
* @param array $response The Heartbeat response.
* @param array $data The `$_POST` data sent.
*
* @return array Heartbeat response received.
*/
public function heartbeat_received( $response, $data ) {
if ( isset( $data['elementor_post_lock']['post_ID'] ) ) {
$post_id = $data['elementor_post_lock']['post_ID'];
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return $response;
}
$locked_user = Plugin::$instance->editor->get_locked_user( $post_id );
if ( ! $locked_user || ! empty( $data['elementor_force_post_lock'] ) ) {
Plugin::$instance->editor->lock_post( $post_id );
} else {
$response['locked_user'] = $locked_user->display_name;
}
if ( array_key_exists( 'elementor_has_unsaved', $data ) ) {
do_action( 'elementor/heartbeat/unsaved_signal', $post_id, $data['elementor_has_unsaved'] );
}
if ( array_key_exists( 'elementor_has_unpersisted', $data ) ) {
do_action( 'elementor/heartbeat/unpersisted_signal', $post_id, $data['elementor_has_unpersisted'] );
}
$mutation_marker = apply_filters( 'elementor/heartbeat/mutation_marker', null, $post_id );
if ( $mutation_marker ) {
$response['elementor_mcp_mutation'] = $mutation_marker;
}
$response['elementor_server_time'] = time();
/** @var Core\Common\Modules\Ajax\Module $ajax */
$ajax = Plugin::$instance->common->get_component( 'ajax' );
$response['elementorNonce'] = $ajax->create_nonce();
}
return $response;
}
/**
* Refresh nonces.
*
* Filter the nonces to send to the editor when editing with Elementor. Used
* to refresh the nonce when the nonce expires while editing. This way the
* user doesn't need to log-in again as Elementor fetches the new nonce from
* the server using ajax.
*
* Fired by `wp_refresh_nonces` filter.
*
* @since 1.8.0
* @access public
*
* @param array $response The no-priv Heartbeat response object or array.
* @param array $data The `$_POST` data sent.
*
* @return array Refreshed nonces.
*/
public function refresh_nonces( $response, $data ) {
if ( isset( $data['elementor_post_lock']['post_ID'] ) ) {
if ( ! current_user_can( 'edit_post', $data['elementor_post_lock']['post_ID'] ) ) {
return $response;
}
/** @var Core\Common\Modules\Ajax\Module $ajax */
$ajax = Plugin::$instance->common->get_component( 'ajax' );
$response['elementor-refresh-nonces'] = [
'elementorNonce' => $ajax->create_nonce(),
'heartbeatNonce' => wp_create_nonce( 'heartbeat-nonce' ),
];
}
return $response;
}
/**
* Heartbeat constructor.
*
* Initializing Elementor heartbeat.
*
* @since 1.0.0
* @access public
*/
public function __construct() {
add_filter( 'heartbeat_received', [ $this, 'heartbeat_received' ], 10, 2 );
add_filter( 'wp_refresh_nonces', [ $this, 'refresh_nonces' ], 30, 2 );
}
}
| nama | waktu | ukuran | owner | perm | aksi |
|---|---|---|---|---|---|
| .. | |||||
| admin-templates/ | 2026-11-25 08:10 | 10.11 KB | 76129f60960:kunden | dxwrx-rx-r | |
| base/ | 2026-11-25 08:10 | 153.85 KB | 76129f60960:kunden | dxwrx-rx-r | |
| controls/ | 2026-11-25 08:10 | 260.89 KB | 76129f60960:kunden | dxwrx-rx-r | |
| editor-templates/ | 2026-11-25 08:10 | 98.46 KB | 76129f60960:kunden | dxwrx-rx-r | |
| elements/ | 2026-11-25 08:10 | 117.77 KB | 76129f60960:kunden | dxwrx-rx-r | |
| interfaces/ | 2026-11-25 08:10 | 730 B | 76129f60960:kunden | dxwrx-rx-r | |
| libraries/ | 2026-11-25 08:10 | 24.14 KB | 76129f60960:kunden | dxwrx-rx-r | |
| managers/ | 2026-11-25 08:10 | 91.38 KB | 76129f60960:kunden | dxwrx-rx-r | |
| settings/ | 2026-11-25 08:10 | 54.34 KB | 76129f60960:kunden | dxwrx-rx-r | |
| template-library/ | 2026-11-25 08:10 | 154.16 KB | 76129f60960:kunden | dxwrx-rx-r | |
| widgets/ | 2026-11-25 08:10 | 510.64 KB | 76129f60960:kunden | dxwrx-rx-r | |
| api.php | 2026-11-25 08:10 | 8.82 KB | 76129f60960:kunden | -xw-x--x-- | |
| autoloader.php | 2026-11-25 08:10 | 9.79 KB | 76129f60960:kunden | -xw-x--x-- | |
| beta-testers.php | 2026-11-25 08:10 | 3.17 KB | 76129f60960:kunden | -xw-x--x-- | |
| compatibility.php | 2026-11-25 08:10 | 10.96 KB | 76129f60960:kunden | -xw-x--x-- | |
| conditions.php | 2026-11-25 08:10 | 2.7 KB | 76129f60960:kunden | -xw-x--x-- | |
| db.php | 2026-11-25 08:10 | 15.89 KB | 76129f60960:kunden | -xw-x--x-- | |
| editor-assets-api.php | 2026-11-25 08:10 | 4.5 KB | 76129f60960:kunden | -xw-x--x-- | |
| embed.php | 2026-11-25 08:10 | 9.57 KB | 76129f60960:kunden | -xw-x--x-- | |
| fonts.php | 2026-11-25 08:10 | 62.53 KB | 76129f60960:kunden | -xw-x--x-- | |
| frontend.php | 2026-11-25 08:10 | 40.02 KB | 76129f60960:kunden | -xw-x--x-- | |
| heartbeat.php | 2026-11-25 08:10 | 3.34 KB | 76129f60960:kunden | -xw-x--x-- | |
| maintenance-mode.php | 2026-11-25 08:10 | 11.16 KB | 76129f60960:kunden | -xw-x--x-- | |
| maintenance.php | 2026-11-25 08:10 | 2.99 KB | 76129f60960:kunden | -xw-x--x-- | |
| plugin.php | 2026-11-25 08:10 | 15.67 KB | 76129f60960:kunden | -xw-x--x-- | |
| preview.php | 2026-11-25 08:10 | 8.21 KB | 76129f60960:kunden | -xw-x--x-- | |
| rollback.php | 2026-11-25 08:10 | 4.16 KB | 76129f60960:kunden | -xw-x--x-- | |
| shapes.php | 2026-11-25 08:10 | 7.81 KB | 76129f60960:kunden | -xw-x--x-- | |
| stylesheet.php | 2026-11-25 08:10 | 8.91 KB | 76129f60960:kunden | -xw-x--x-- | |
| tracker.php | 2026-11-25 08:10 | 17 KB | 76129f60960:kunden | -xw-x--x-- | |
| user-data.php | 2026-11-25 08:10 | 3.67 KB | 76129f60960:kunden | -xw-x--x-- | |
| user.php | 2026-11-25 08:10 | 10.11 KB | 76129f60960:kunden | -xw-x--x-- | |
| utils.php | 2026-11-25 08:10 | 30.51 KB | 76129f60960:kunden | -xw-x--x-- | |