Skip to content

Commit

Permalink
Merge branch 'release/1.0.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
Misplon committed Sep 13, 2017
2 parents 3ecdc07 + 4701cea commit 5bfd9fe
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 15 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
== Changelog ==

= 1.0.8 - 13 September 2017 =
* Added support for the WooCommerce store notice.

= 1.0.7 - 25 August 2017 =
* Added minimal UberMenu support.
* Removed WooCommerce product hover buttons on mobile.
Expand Down
5 changes: 5 additions & 0 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<div id="page" class="site">
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'polestar' ); ?></a>

<?php if ( class_exists( 'Woocommerce' ) && is_store_notice_showing() ) : ?>
<div id="topbar">
<?php polestar_woocommerce_demo_store(); ?>
</div><!-- #topbar -->
<?php endif; ?>
<header id="masthead" class="site-header<?php if ( get_theme_mod( 'header_layout' ) == 'centered' ) echo ' centered'; if ( get_theme_mod( 'sticky_header', true ) ) echo ' sticky'; if ( get_theme_mod( 'mobile_menu', true ) ) echo ' mobile-menu'; ?>" role="banner" <?php if ( get_theme_mod( 'sticky_header_scaling', true ) ) echo 'data-scale-logo="true"' ?> >

<div class="polestar-container">
Expand Down
9 changes: 8 additions & 1 deletion inc/extras.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ function polestar_body_classes( $classes ) {
$classes[] = 'sidebar-left';
}

// WooCommerce top bar.
if ( class_exists( 'Woocommerce' ) && ! is_store_notice_showing() ) {
$classes[] = 'no-topbar';
} elseif ( ! class_exists( 'Woocommerce' ) ) {
$classes[] = 'no-topbar';
}

// WooCommerce columns.
if ( get_theme_mod( 'archive_columns' ) ) {
$classes[] = 'wc-columns-' . get_theme_mod( 'archive_columns' );
Expand All @@ -69,7 +76,7 @@ function polestar_body_classes( $classes ) {

if ( get_theme_mod( 'woocommerce_sidebar_position' ) == 'right' ) {
$classes[] = 'woocommerce-sidebar-right';
}
}

return $classes;
}
Expand Down
31 changes: 25 additions & 6 deletions js/jquery.theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
jQuery( function( $ ) {

// Element viewport visibility.
$.fn.isVisible = function() {
$.fn.polestarIsVisible = function() {
var rect = this[0].getBoundingClientRect();
return (
rect.bottom >= 0 &&
rect.right >= 0 &&
rect.top <= ( window.innerHeight || document.documentElement.clientHeight ) &&
rect.left <= ( window.innerWidth || document.documentElement.clientWidth )
rect.top <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.left <= (window.innerWidth || document.documentElement.clientWidth)
);
};
};

// Entry thumbnail container size.
$( window ).load( function() {
Expand Down Expand Up @@ -110,7 +110,9 @@ jQuery( function( $ ) {
if ( $( '#masthead' ).hasClass( 'sticky' ) ) {
var $mhs = false,
pageTop = $( '#page' ).offset().top,
$mh = $( '#masthead' );
$mh = $( '#masthead' ),
$tb = $( '#topbar' ),
$tbwc = $('#topbar .woocommerce-store-notice[style*="display: none"]');

var smSetup = function() {

Expand All @@ -119,7 +121,24 @@ jQuery( function( $ ) {
$mhs.css( 'height', $mh.outerHeight() );
}

$mh.css( 'position', 'fixed' );
if ( ! $( 'body' ).hasClass( 'no-topbar' ) && ! $tb.polestarIsVisible() ) {
$( 'body' ).addClass( 'topbar-out' );
}

if ( $tb.length && $( 'body' ).hasClass( 'topbar-out' ) && $tb.polestarIsVisible() ) {
$( 'body' ).removeClass( 'topbar-out' );
}

if ( $( 'body' ).hasClass( 'no-topbar' ) && ! $( window ).scrollTop() ) {
$( 'body' ).addClass( 'topbar-out' );
}

if ( $( 'body' ).hasClass( 'no-topbar' ) || ( ! $( 'body' ).hasClass( 'no-topbar' ) && $( 'body' ).hasClass( 'topbar-out' ) ) || $tbwc.length ) {
$mh.css( 'position', 'fixed' );
} else if ( ! $( 'body' ).hasClass( 'no-topbar' ) && ! $( 'body' ).hasClass( 'topbar-out' ) ) {
$mh.css( 'position', 'absolute' );
}

};
smSetup();
$( window ).resize( smSetup ).scroll( smSetup );
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Contributors: Puro
Tags: two-columns, right-sidebar, custom-background, custom-menu, custom-logo, featured-images, footer-widgets, sticky-post, threaded-comments, translation-ready, blog, e-commerce

Requires at least: 4.7
Tested up to: 4.8
Tested up to: 4.8.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down
29 changes: 29 additions & 0 deletions sass/site/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@
.no-header-margin & {
margin-bottom: 0;
}

@at-root {

.topbar-out & {
@include clearfix;
top: 0;
left: 0;
width: 100%;
}

.topbar-out.admin-bar & {
top: 32px;

@media (max-width: 782px) {
top: 46px;
}

@media (max-width: 600px) {
position: fixed;
top: 0;
}
}
}

@media (max-width: 600px) {

Expand Down Expand Up @@ -204,3 +227,9 @@
margin-bottom: 0;
}
}

#topbar {
position: relative;
width: 100%;
z-index: 1000;
}
9 changes: 5 additions & 4 deletions sass/woocommerce/_notifications.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@

.woocommerce-store-notice {
justify-content: center;
position: absolute;
margin: 0;
// position: absolute;
text-align: center;
top: 0;
width: 100%;
z-index: 9999;

@at-root .admin-bar & {
top: 32px;
}
// @at-root .admin-bar & {
// top: 32px;
// }

@media (max-width: 768px) {
display: flex;
Expand Down
22 changes: 22 additions & 0 deletions style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions woocommerce.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions woocommerce/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,30 @@ function polestar_woocommerce_change_hooks() {
add_action( 'polestar_woocommerce_quick_view_content', 'woocommerce_template_single_excerpt', 15 );
add_action( 'polestar_woocommerce_quick_view_content', 'woocommerce_template_single_add_to_cart', 20 );

// Remove store notice hook.
remove_action( 'wp_footer', 'woocommerce_demo_store' );

}
endif;
add_action( 'after_setup_theme', 'polestar_woocommerce_change_hooks' );

/**
* Output the store notification.
*/
function polestar_woocommerce_demo_store() {
if ( ! is_store_notice_showing() ) {
return;
}

$notice = get_option( 'woocommerce_demo_store_notice' );

if ( empty( $notice ) ) {
$notice = __( 'This is a demo store for testing purposes &mdash; no orders shall be fulfilled.', 'polestar' );
}

echo '<p class="woocommerce-store-notice demo_store">' . wp_kses_post( $notice ) . ' <a href="#" class="woocommerce-store-notice__dismiss-link">' . esc_html__( 'Dismiss', 'polestar' ) . '</a></p>';
}

if ( ! function_exists( 'polestar_woocommerce_archive_product_image' ) ) :
/**
* Archive product images.
Expand Down

0 comments on commit 5bfd9fe

Please sign in to comment.