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

Fixed shop page layout container width issue #4350

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
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
40 changes: 33 additions & 7 deletions inc/compatibility/woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ class Woocommerce {
*/
private $sidebar_manager;

/**
* Store elementor location flag.
*
* @var bool $is_elementor_location
*/
private $is_elementor_location = false;

/**
* Initialize the module.
*/
Expand Down Expand Up @@ -283,18 +290,24 @@ public function register_hooks() {
add_action( 'admin_init', array( $this, 'set_update_woo_width_flag' ), 9 );
add_action( 'admin_footer', array( $this, 'update_woo_width' ) );

// Handle shop sidebar.
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );

// Wrap content.
add_action( 'neve_after_primary_start', array( $this, 'wrap_pages_start' ) );
add_action( 'neve_before_primary_end', array( $this, 'wrap_pages_end' ) );
$this->is_elementor_location = function_exists( 'elementor_location_exits' ) && elementor_location_exits( 'header', true );
if ( $this->is_elementor_location ) {
add_action( 'woocommerce_before_main_content', array( $this, 'wrap_pages_start' ) );
add_action( 'woocommerce_after_main_content', array( $this, 'wrap_pages_end' ) );
} else {
add_action( 'neve_after_primary_start', array( $this, 'wrap_pages_start' ) );
add_action( 'neve_before_primary_end', array( $this, 'wrap_pages_end' ) );
add_action( 'woocommerce_before_main_content', array( $this, 'shop_sidebar_left' ) );
add_action( 'woocommerce_sidebar', array( $this, 'shop_sidebar_right' ) );
}

add_action( 'woocommerce_before_main_content', array( $this, 'wrap_main_content_start' ), 15 );
add_action( 'woocommerce_after_main_content', array( $this, 'close_div' ), 15 );

// Handle shop sidebar.
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
add_action( 'woocommerce_before_main_content', array( $this, 'shop_sidebar_left' ) );
add_action( 'woocommerce_sidebar', array( $this, 'shop_sidebar_right' ) );

/**
* Change product page sidebar default position
* Priority 9 to allow meta control to override this value
Expand Down Expand Up @@ -526,6 +539,9 @@ public function close_div() {
* Wrap main content start.
*/
public function wrap_main_content_start() {
if ( $this->is_elementor_location ) {
$this->shop_sidebar_left();
}
$before_shop_classes = apply_filters( 'neve_before_shop_classes', 'nv-index-posts nv-shop col' );
echo '<div class="' . esc_attr( $before_shop_classes ) . '">';
do_action( 'neve_before_shop_loop_content' );
Expand All @@ -538,6 +554,10 @@ public function wrap_pages_start() {
if ( ! is_woocommerce() ) {
return;
}

if ( doing_action( 'woocommerce_before_main_content' ) ) {
echo '<main id="content" class="neve-main">';
}
echo '<div class="' . esc_attr( apply_filters( 'neve_container_class_filter', 'container' ) ) . ' shop-container">';
echo '<div class="row">';
}
Expand All @@ -550,7 +570,13 @@ public function wrap_pages_end() {
return;
}
$this->close_div();
if ( $this->is_elementor_location ) {
$this->shop_sidebar_right();
}
$this->close_div();
if ( doing_action( 'neve_before_primary_end' ) ) {
$this->close_div();
}
}

/**
Expand Down
Loading