Skip to content

Commit

Permalink
ESI - Add Edit with Elementor
Browse files Browse the repository at this point in the history
Add admin bar to "wp_body_open"
Also make sure is loaded just once.
Tested the fix for PHP 5 too
  • Loading branch information
Tymotey committed Jun 24, 2024
1 parent 9a2ffc9 commit 5db36f2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/esi.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ private function _register_not_esi_actions()

// Add admin_bar esi
if (Router::is_logged_in()) {
// Remove default Admin bar. Fix https://github.com/elementor/elementor/issues/25198
remove_action('wp_body_open', 'wp_admin_bar_render', 0);
add_action('wp_body_open', array($this, 'sub_admin_bar_block'), 0);
remove_action('wp_footer', 'wp_admin_bar_render', 1000);
add_action('wp_footer', array($this, 'sub_admin_bar_block'), 1000);
}
Expand Down Expand Up @@ -760,7 +763,12 @@ public function sub_widget_block($instance, $widget, $args)
public function sub_admin_bar_block()
{
global $wp_admin_bar;
static $rendered = false;

if ( $rendered ) {
return;
}

if (!is_admin_bar_showing() || !is_object($wp_admin_bar)) {
return;
}
Expand All @@ -771,6 +779,8 @@ public function sub_admin_bar_block()
);

echo $this->sub_esi_block('admin-bar', 'adminbar', $params);

$rendered = true;
}

/**
Expand Down

0 comments on commit 5db36f2

Please sign in to comment.