Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: elementor do_location usage method refactored #3304

Merged
merged 1 commit into from
Jan 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions inc/compatibility/elementor.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
*/
class Elementor extends Page_Builder_Base {

/**
* Elementor location manager
*
* @var \ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager
*/
public $elementor_location_manager;

/**
* Init function.
*/
Expand Down Expand Up @@ -156,6 +149,10 @@ public function add_theme_builder_hooks() {
// Elementor locations compatibility. (This action fires by Elementor Pro)
add_action( 'elementor/theme/register_locations', array( $this, 'register_theme_locations' ) );

if ( ! function_exists( 'elementor_theme_do_location' ) ) {
return;
}

// Override theme templates.
add_action( 'neve_do_top_bar', array( $this, 'do_header' ), 0 );
add_action( 'neve_do_header', array( $this, 'do_header' ), 0 );
Expand All @@ -174,14 +171,13 @@ public function add_theme_builder_hooks() {
*/
public function register_theme_locations( $manager ) {
$manager->register_all_core_location();
$this->elementor_location_manager = \ElementorPro\Modules\ThemeBuilder\Module::instance()->get_locations_manager();
}

/**
* Remove actions for elementor header to act properly.
*/
public function do_header() {
$did_location = $this->elementor_location_manager->do_location( 'header' );
$did_location = elementor_theme_do_location( 'header' );
if ( $did_location ) {
remove_all_actions( 'neve_do_top_bar' );
remove_all_actions( 'neve_do_header' );
Expand All @@ -192,7 +188,7 @@ public function do_header() {
* Remove actions for elementor footer to act properly.
*/
public function do_footer() {
$did_location = $this->elementor_location_manager->do_location( 'footer' );
$did_location = elementor_theme_do_location( 'footer' );
if ( $did_location ) {
remove_all_actions( 'neve_do_footer' );
}
Expand All @@ -205,7 +201,7 @@ public function do_404() {
if ( ! is_404() ) {
return;
}
$did_location = $this->elementor_location_manager->do_location( 'single' );
$did_location = elementor_theme_do_location( 'single' );
if ( $did_location ) {
remove_all_actions( 'neve_do_404' );
}
Expand All @@ -215,7 +211,7 @@ public function do_404() {
* Remove actions for elementor single post to act properly.
*/
public function do_single_post() {
$did_location = $this->elementor_location_manager->do_location( 'single' );
$did_location = elementor_theme_do_location( 'single' );
if ( $did_location ) {
remove_all_actions( 'neve_do_single_post' );
}
Expand All @@ -225,7 +221,7 @@ public function do_single_post() {
* Remove actions for elementor single page to act properly.
*/
public function do_single_page() {
$did_location = $this->elementor_location_manager->do_location( 'single' );
$did_location = elementor_theme_do_location( 'single' );
if ( $did_location ) {
remove_all_actions( 'neve_do_single_page' );
}
Expand Down