Last updated on October 18, 2023

Elementor undo/redo not working

Don’t know where to add this snippet? Read our guide: How to add code snippets.

Make Elementor undo/redo work seamlessly.

If Elementor’s undo/redo functionality is not working properly, you can try the following code snippet to fix the issue. This code snippet will enqueue a script that will enable the undo/redo functionality in Elementor.

function wpsnippets_enable_elementor_undo_redo() {
    if ( ! did_action( 'elementor/loaded' ) ) {
        return;
    }

    wp_enqueue_script( 'wpsnippets-elementor-undo-redo', plugin_dir_url( __FILE__ ) . 'js/elementor-undo-redo.js', array( 'jquery' ), '1.0', true );
}
add_action( 'admin_enqueue_scripts', 'wpsnippets_enable_elementor_undo_redo' );

To use this code snippet, you need to create a new file named elementor-undo-redo.js in your plugin or theme directory. In that file, you can add the following JavaScript code:

jQuery( document ).ready( function( $ ) {
    if ( typeof elementorCommon !== 'undefined' ) {
        elementorCommon.history = new elementorCommon.History();
    }
});

This code snippet checks if the Elementor plugin is loaded and then initializes the Elementor history object, which is responsible for the undo/redo functionality.

By adding this code snippet to your WordPress site, you should be able to fix the issue with Elementor’s undo/redo functionality not working.

Examples

Example #1: Checking for Plugin Conflicts

This use case involves checking for conflicts with other plugins that may be causing the Elementor undo/redo feature to not work. The code example below demonstrates how to disable all other plugins except Elementor to identify if a conflict exists.

function wpsnippets_disable_plugins_except_elementor() {
    $elementor_plugin = 'elementor/elementor.php';

    // Get all active plugins
    $active_plugins = get_option('active_plugins');

    // Deactivate all plugins except Elementor
    foreach ($active_plugins as $plugin) {
        if ($plugin !== $elementor_plugin) {
            deactivate_plugins($plugin);
        }
    }
}
add_action('admin_init', 'wpsnippets_disable_plugins_except_elementor');

The code above creates a custom function wpsnippets_disable_plugins_except_elementor that gets all active plugins and deactivates them except for Elementor. This allows you to test if any other plugins are causing conflicts with Elementor’s undo/redo functionality.

Example #2: Increasing Memory Limit

In some cases, the Elementor undo/redo feature may not work due to insufficient memory limit. The code example below demonstrates how to increase the memory limit for WordPress.

function wpsnippets_increase_memory_limit() {
    define('WP_MEMORY_LIMIT', '256M');
}
add_action('init', 'wpsnippets_increase_memory_limit');

The code above sets the WordPress memory limit to 256MB by defining the WP_MEMORY_LIMIT constant. This can help resolve issues with Elementor’s undo/redo feature not working due to memory constraints.

Example #3: Clearing Elementor Cache

Another possible reason for Elementor’s undo/redo feature not working is a cache conflict. The code example below demonstrates how to clear Elementor’s cache programmatically.

function wpsnippets_clear_elementor_cache() {
    if (class_exists('ElementorPlugin')) {
        ElementorPlugin::$instance->files_manager->clear_cache();
    }
}
add_action('wp_footer', 'wpsnippets_clear_elementor_cache');

The code above creates a custom function wpsnippets_clear_elementor_cache that checks if the Elementor plugin is active and clears its cache using the clear_cache() method. This can help resolve issues with Elementor’s undo/redo feature not working due to cache conflicts.

Last updated on October 18, 2023. Originally posted on December 1, 2023.

Leave a Reply