Merge pull request #23384 from CasperBraske/CasperBraske-patch-1
Moved HTML from widget code to template file
This commit is contained in:
commit
353945f638
|
@ -120,21 +120,17 @@ class WC_Widget_Price_Filter extends WC_Widget {
|
|||
$form_action = preg_replace( '%\/page/[0-9]+%', '', home_url( trailingslashit( $wp->request ) ) );
|
||||
}
|
||||
|
||||
echo '<form method="get" action="' . esc_url( $form_action ) . '">
|
||||
<div class="price_slider_wrapper">
|
||||
<div class="price_slider" style="display:none;"></div>
|
||||
<div class="price_slider_amount" data-step="' . esc_attr( $step ) . '">
|
||||
<input type="text" id="min_price" name="min_price" value="' . esc_attr( $current_min_price ) . '" data-min="' . esc_attr( $min_price ) . '" placeholder="' . esc_attr__( 'Min price', 'woocommerce' ) . '" />
|
||||
<input type="text" id="max_price" name="max_price" value="' . esc_attr( $current_max_price ) . '" data-max="' . esc_attr( $max_price ) . '" placeholder="' . esc_attr__( 'Max price', 'woocommerce' ) . '" />
|
||||
<button type="submit" class="button">' . esc_html__( 'Filter', 'woocommerce' ) . '</button>
|
||||
<div class="price_label" style="display:none;">
|
||||
' . esc_html__( 'Price:', 'woocommerce' ) . ' <span class="from"></span> — <span class="to"></span>
|
||||
</div>
|
||||
' . wc_query_string_form_fields( null, array( 'min_price', 'max_price', 'paged' ), '', true ) . '
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</form>'; // WPCS: XSS ok.
|
||||
wc_get_template(
|
||||
'content-widget-price-filter.php',
|
||||
array(
|
||||
'form_action' => $form_action,
|
||||
'step' => $step,
|
||||
'min_price' => $min_price,
|
||||
'max_price' => $max_price,
|
||||
'current_min_price' => $current_min_price,
|
||||
'current_max_price' => $current_max_price,
|
||||
)
|
||||
);
|
||||
|
||||
$this->widget_end( $args );
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
* The template for displaying product price filter widget.
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/content-widget-price-filter.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/
|
||||
* @package WooCommerce/Templates
|
||||
* @version 3.7.1
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
?>
|
||||
<?php do_action( 'woocommerce_widget_price_filter_start', $args ); ?>
|
||||
|
||||
<form method="get" action="<?php echo esc_url( $form_action ); ?>">
|
||||
<div class="price_slider_wrapper">
|
||||
<div class="price_slider" style="display:none;"></div>
|
||||
<div class="price_slider_amount" data-step="<?php echo esc_attr( $step ); ?>">
|
||||
<input type="text" id="min_price" name="min_price" value="<?php echo esc_attr( $current_min_price ); ?>" data-min="<?php echo esc_attr( $min_price ); ?>" placeholder="<?php echo esc_attr__( 'Min price', 'woocommerce' ); ?>" />
|
||||
<input type="text" id="max_price" name="max_price" value="<?php echo esc_attr( $current_max_price ); ?>" data-max="<?php echo esc_attr( $max_price ); ?>" placeholder="<?php echo esc_attr__( 'Max price', 'woocommerce' ); ?>" />
|
||||
<?php /* translators: Filter: verb "to filter" */ ?>
|
||||
<button type="submit" class="button"><?php echo esc_html__( 'Filter', 'woocommerce' ); ?></button>
|
||||
<div class="price_label" style="display:none;">
|
||||
<?php echo esc_html__( 'Price:', 'woocommerce' ); ?> <span class="from"></span> — <span class="to"></span>
|
||||
</div>
|
||||
<?php echo wc_query_string_form_fields( null, array( 'min_price', 'max_price', 'paged' ), '', true ); ?>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php do_action( 'woocommerce_widget_price_filter_end', $args ); ?>
|
Loading…
Reference in New Issue