Skip to content

Commit

Permalink
Merge pull request #208 from BoldGrid/issue-66
Browse files Browse the repository at this point in the history
add page title to cart and checkout pages
  • Loading branch information
jamesros161 authored Jun 10, 2020
2 parents 45a39a2 + 705d637 commit 7d95787
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
55 changes: 40 additions & 15 deletions src/includes/class-boldgrid-framework-woocommerce.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* Class: BoldGrid_Framework_Woocommerce
* Class: BoldGrid_Framework_Woocommerce.
*
* This is where all wooCommerce specific functionality is manipulated, outside
* This is where all wooCommerce specific functionality is manipulated, outside.
* of custom templates used by parent themes.
*
* @since 1.4.1
Expand All @@ -12,9 +12,9 @@
*/

/**
* Class: BoldGrid_Framework_Woocommerce
* Class: BoldGrid_Framework_Woocommerce.
*
* This is where all wooCommerce specific functionality is manipulated, outside
* This is where all wooCommerce specific functionality is manipulated, outside.
* of custom templates used by parent themes.
*
* @since 1.4.1
Expand Down Expand Up @@ -43,7 +43,7 @@ public function __construct( $configs ) {
/**
* Filter add_to_cart_url.
*
* This is responsible for filtering the add to cart buttons used throughout
* This is responsible for filtering the add to cart buttons used throughout.
* wooCommerce and placing our button classes on them.
*
* @global $product wooCommerce global product info.
Expand All @@ -54,7 +54,8 @@ public function __construct( $configs ) {
*/
public function buttons( $link ) {
global $product;
$link = sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s">%s</a>',
$link = sprintf(
'<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s">%s</a>',
esc_url( $product->add_to_cart_url() ),
esc_attr( isset( $quantity ) ? $quantity : 1 ),
esc_attr( $product->get_id() ),
Expand Down Expand Up @@ -131,7 +132,7 @@ public function remove_select2() {
* @return bool Is current page a woocommerce page.
*/
public function is_woocommerce_page() {
return ( bool ) ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) || array_filter(
return (bool) ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) || array_filter(
array(
'woocommerce_shop_page_id',
'woocommerce_terms_page_id',
Expand All @@ -147,7 +148,7 @@ public function is_woocommerce_page() {
'woocommerce_lost_password_page_id',
),
function( $id ) {
return get_the_ID() == get_option( $id , 0 );
return get_the_ID() === (int) get_option( $id, 0 );
}
);
}
Expand All @@ -159,20 +160,20 @@ function( $id ) {
* @return bool Is current page a woocommerce shop page ( shop, archive, or product ).
*/
public function is_shop_page() {
return ( bool ) ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) || array_filter(
return (bool) ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) || array_filter(
array(
'woocommerce_shop_page_id',
),
function( $id ) {
return get_the_ID() == get_option( $id , 0 );
return get_the_ID() === (int) get_option( $id, 0 );
}
);
}

/**
* Adds select2 styles to match our theme.
*
* Woocommerce adds select to for their dropdowns, which creates a better
* Woocommerce adds select to for their dropdowns, which creates a better.
* user experience overall. The styles conflict with the native styles of
* bootstrap, so we add our bootstrap select2 style conditionally if woocommerce
* class is present, and we are on the checkout page. This needs to be enqueued
Expand All @@ -197,7 +198,8 @@ public function enqueue() {
'bgtfw-woo-quantity',
$this->configs['framework']['js_dir'] . 'woocommerce/quantity' . $suffix . '.js',
array( 'jquery' ),
'1.4.6'
'1.4.6',
true
);
}

Expand All @@ -209,7 +211,8 @@ public function enqueue() {
'bgtfw-woo-tabs',
$this->configs['framework']['js_dir'] . 'woocommerce/tabs' . $suffix . '.js',
array( 'jquery' ),
'1.4.6'
'1.4.6',
true
);
}

Expand All @@ -222,7 +225,8 @@ public function enqueue() {
'bgtfw-woo-user-login',
$this->configs['framework']['js_dir'] . 'woocommerce/user-login' . $suffix . '.js',
array( 'jquery' ),
'1.4.6'
'1.4.6',
true
);
}
}
Expand All @@ -231,7 +235,7 @@ public function enqueue() {
/**
* Filter for wooCommerce Breadcrumbs.
*
* We use this to apply some of our color classes to the breadcrumb output,
* We use this to apply some of our color classes to the breadcrumb output.
* and to style the Home URL as a Home icon.
*
* @return Array The new breadcrumb arguments to apply to filter.
Expand Down Expand Up @@ -301,6 +305,10 @@ public function quantity_input_after() {
* Filters the input classes on quantity inputs.
*
* @since 2.1.4
*
* @param array $classes An array of classes.
*
* @return array
*/
public function quantity_input_classes( $classes ) {
$classes[] = 'form-control';
Expand All @@ -309,6 +317,23 @@ public function quantity_input_classes( $classes ) {
}

/**
* Adds page title to a shop Page.
*
* @since 2.2.16
*/
public function add_page_title() {
if ( 'hide' !== get_theme_mod( 'bgtfw_pages_title_display' ) ) {
$slug = get_post_field( 'post_name', get_post() );
$markup = '
<header class="woocommerce-' . esc_attr( $slug ) . '-header">
<h1 class="woocommerce-' . esc_attr( $slug ) . '-header__title page-title">
' . esc_attr( get_the_title() ) . '
</h1>
</header>';
echo $markup; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

* Changes the number of products shown per page.
*
* @since 2.2.16
Expand Down
2 changes: 2 additions & 0 deletions src/includes/class-boldgrid-framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,8 @@ private function woocommerce() {
$this->loader->add_filter( 'woocommerce_quantity_input_classes', $woo, 'quantity_input_classes' );
$this->loader->add_action( 'woocommerce_before_quantity_input_field', $woo, 'quantity_input_before' );
$this->loader->add_action( 'woocommerce_after_quantity_input_field', $woo, 'quantity_input_after' );
$this->loader->add_action( 'woocommerce_before_cart', $this->woo, 'add_page_title' );
$this->loader->add_action( 'woocommerce_before_checkout_form', $this->woo, 'add_page_title' );

remove_all_actions( 'woocommerce_sidebar' );
add_filter( 'loop_shop_per_page', function( $cols ) {
Expand Down

0 comments on commit 7d95787

Please sign in to comment.