Remove woocommerce.php and replace it with hooked version
See https://github.com/understrap/understrap/issues/606#issuecomment-3753920 87 Thx @ZacharyElkins !
This commit is contained in:
parent
6fc18522f7
commit
a2fa9e56ba
|
@ -21,6 +21,39 @@ if ( ! function_exists( 'understrap_woocommerce_support' ) ) {
|
|||
add_filter( 'woocommerce_form_field_args', 'understrap_wc_form_field_args', 10, 3 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* First unhook the WooCommerce wrappers
|
||||
*/
|
||||
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
|
||||
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
|
||||
|
||||
/**
|
||||
* Then hook in your own functions to display the wrappers your theme requires
|
||||
*/
|
||||
add_action('woocommerce_before_main_content', 'understrap_woocommerce_wrapper_start', 10);
|
||||
add_action('woocommerce_after_main_content', 'understrap_woocommerce_wrapper_end', 10);
|
||||
if ( ! function_exists( 'understrap_woocommerce_wrapper_start' ) ) {
|
||||
function understrap_woocommerce_wrapper_start() {
|
||||
$container = get_theme_mod( 'understrap_container_type' );
|
||||
echo '<div class="wrapper" id="woocommerce-wrapper">';
|
||||
echo '<div class="' . esc_attr( $container ) . '" id="content" tabindex="-1">';
|
||||
echo '<div class="row">';
|
||||
get_template_part( 'global-templates/left-sidebar-check' );
|
||||
echo '<main class="site-main" id="main">';
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'understrap_woocommerce_wrapper_end' ) ) {
|
||||
function understrap_woocommerce_wrapper_end() {
|
||||
echo '</main><!-- #main -->';
|
||||
echo '</div><!-- #primary -->';
|
||||
get_template_part( 'global-templates/right-sidebar-check' );
|
||||
echo '</div><!-- .row -->';
|
||||
echo '</div><!-- Container end -->';
|
||||
echo '</div><!-- Wrapper end -->';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter hook function monkey patching form classes
|
||||
* Author: Adriano Monecchi http://stackoverflow.com/a/36724593/307826
|
||||
|
@ -98,3 +131,4 @@ function understrap_wc_form_field_args( $args, $key, $value = null ) {
|
|||
} // end switch ($args).
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* The template for displaying all woocommerce pages.
|
||||
*
|
||||
* This is the template that displays all pages by default.
|
||||
* Please note that this is the WordPress construct of pages
|
||||
* and that other 'pages' on your WordPress site will use a
|
||||
* different template.
|
||||
*
|
||||
* @package understrap
|
||||
*/
|
||||
|
||||
get_header();
|
||||
|
||||
$container = get_theme_mod( 'understrap_container_type' );
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<div class="wrapper" id="woocommerce-wrapper">
|
||||
|
||||
<div class="<?php echo esc_attr( $container ); ?>" id="content" tabindex="-1">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<!-- Do the left sidebar check -->
|
||||
<?php get_template_part( 'global-templates/left-sidebar-check' ); ?>
|
||||
|
||||
<main class="site-main" id="main">
|
||||
|
||||
<?php
|
||||
$template_name = '\archive-product.php';
|
||||
$args = array();
|
||||
$template_path = '';
|
||||
$default_path = untrailingslashit( plugin_dir_path(__FILE__) ) . '\woocommerce';
|
||||
|
||||
if ( is_singular( 'product' ) ) {
|
||||
|
||||
woocommerce_content();
|
||||
|
||||
//For ANY product archive, Product taxonomy, product search or /shop landing page etc Fetch the template override;
|
||||
} elseif ( file_exists( $default_path . $template_name ) )
|
||||
{
|
||||
wc_get_template( $template_name, $args, $template_path, $default_path );
|
||||
|
||||
//If no archive-product.php template exists, default to catchall;
|
||||
} else {
|
||||
woocommerce_content( );
|
||||
}
|
||||
|
||||
;?>
|
||||
|
||||
</main><!-- #main -->
|
||||
|
||||
</div><!-- #primary -->
|
||||
|
||||
<!-- Do the right sidebar check -->
|
||||
<?php get_template_part( 'global-templates/right-sidebar-check' ); ?>
|
||||
|
||||
</div><!-- .row -->
|
||||
|
||||
</div><!-- Container end -->
|
||||
|
||||
</div><!-- Wrapper end -->
|
||||
|
||||
<?php get_footer(); ?>
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Content wrappers
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/global/wrapper-end.php.
|
||||
*
|
||||
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
||||
* (the theme developer) will need to copy the new files to your theme to
|
||||
* maintain compatibility. We try to do this as little as possible, but it does
|
||||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see https://docs.woocommerce.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 3.3.2
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
?>
|
||||
</div></div></div>
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Content wrappers
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/global/wrapper-start.php.
|
||||
*
|
||||
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
||||
* (the theme developer) will need to copy the new files to your theme to
|
||||
* maintain compatibility. We try to do this as little as possible, but it does
|
||||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see https://docs.woocommerce.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 3.3.2
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
// load container setting
|
||||
$container = get_theme_mod( 'understrap_container_type' );
|
||||
|
||||
// if we use container-fluid add some margin
|
||||
if ( 'container-fluid' === $container ) {
|
||||
echo '<div class="wrapper" id="page-wrapper"><div class="' . $container . '" id="content" tabindex="-1"> <div class="row mx-1">';
|
||||
} else {
|
||||
echo '<div class="wrapper" id="page-wrapper"><div class="' . $container . '" id="content" tabindex="-1"> <div class="row">';
|
||||
}
|
Reference in New Issue