Skip to content

Commit

Permalink
ESI - Add Edit with Elementor (#635)
Browse files Browse the repository at this point in the history
* ESI - Add Edit with Elementor

Add admin bar to "wp_body_open"
Also make sure is loaded just once.
Tested the fix for PHP 5 too

* Move rendered to class level

* Review change

---------

Co-authored-by: Timotei <[email protected]>
  • Loading branch information
2 people authored and Hai Zheng committed Jul 29, 2024
1 parent 48dd39b commit 2d7ffc6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/esi.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ESI extends Root

private static $has_esi = false;
private static $_combine_ids = array();
private $admin_rendered = false;
private $esi_args = null;
private $_esi_preserve_list = array();
private $_nonce_actions = array(-1 => ''); // val is cache control
Expand Down Expand Up @@ -364,6 +365,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 @@ -766,6 +770,10 @@ public function sub_admin_bar_block()
{
global $wp_admin_bar;

if ( $this->admin_rendered ) {
return;
}

if (!is_admin_bar_showing() || !is_object($wp_admin_bar)) {
return;
}
Expand All @@ -775,6 +783,7 @@ public function sub_admin_bar_block()
'ref' => $_SERVER['REQUEST_URI'],
);

$this->admin_rendered = true;
echo $this->sub_esi_block('admin-bar', 'adminbar', $params);
}

Expand Down

0 comments on commit 2d7ffc6

Please sign in to comment.