-
-
Save calvez/7a92ec683929050165529ab7b99bf50d to your computer and use it in GitHub Desktop.
In WooCommerce, make the online store notice only show up in store pages as opposed to the entire site, which is the default behaviour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( ! function_exists( 'woocommerce_demo_store' ) ) { | |
/** | |
* Adds a demo store banner to the site if enabled | |
* | |
* @access public | |
* @return void | |
*/ | |
function woocommerce_demo_store() { | |
if ( get_option( 'woocommerce_demo_store' ) == 'no' ) | |
return; | |
$notice = get_option( 'woocommerce_demo_store_notice' ); | |
if ( empty( $notice ) ) | |
$notice = __( 'This is a demo store for testing purposes — no orders shall be fulfilled.', 'woocommerce' ); | |
if (! is_woocommerce () ) | |
echo apply_filters( 'woocommerce_demo_store', '<p class="demo_store" style="display:none;">' . $notice . '</p>' ); | |
else echo apply_filters( 'woocommerce_demo_store', '<p class="demo_store">' . $notice . '</p>' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment