Skip to content

Instantly share code, notes, and snippets.

View Willem-Siebe's full-sized avatar

Willem-Siebe

View GitHub Profile
@Willem-Siebe
Willem-Siebe / functions.php
Last active July 9, 2017 13:35
Remove CSS from WooCommerce 2.1 and further, see http://jameskoster.co.uk/snippets/disable-woocommerce-styles/.
// Remove CSS from WooCommerce after version 2.1, see https://gist.github.com/Willem-Siebe/8c29bcfa791316165127.
add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );
@Willem-Siebe
Willem-Siebe / functions.php
Last active August 29, 2015 14:02
Register multiple WordPress menu's, see http://codex.wordpress.org/Function_Reference/register_nav_menus. Here I use my own function since the parent theme, Toolset Bootstrap, is not using a filter for this.
// Register multiple WordPress menu's, see https://gist.github.com/Willem-Siebe/40311753fce4bfb5fd62.
function wsis_register_nav_menus() {
register_nav_menus(array(
'support_navigation' => 'Support Navigation',
'shop_navigation' => 'Shop Navigation',
'social_navigation' => 'Social Navigation',
'footer_navigation' => 'Footer Navigation',
)); }
@Willem-Siebe
Willem-Siebe / functions.php
Last active August 29, 2015 14:02
Overwrite navbar classes given by parent Toolset Bootstrap theme, possible because they only use there function if we don't declare one with the same function name, which in this case we do. We do this to remove the original 'span12' used by parent theme. See http://wp-types.com/forums/topic/update-1-1-toolset-bootstrap/.
// Remove 'span12' class from main navigation, see https://gist.github.com/Willem-Siebe/02d97fd251a1967a8adc.
function wpbootstrap_get_nav_menu_classes() {
$wpbootstrap_navbar_classes = 'navbar';
if ( of_get_option( 'navbar_style' ) === 'menu_static' ) {
$wpbootstrap_navbar_classes = $wpbootstrap_navbar_classes . '';
@Willem-Siebe
Willem-Siebe / functions.php
Last active August 29, 2015 14:02
Overwrite Toolset Bootstrap parent theme widget arrays. For example, change 'aside' for sidebar widget to 'section' when using Toolset Bootstrap parent theme. Because of the 'if' statement in parent theme functions.php I can overwrite this by declaring the same function name in my child theme functions.php. Other method: http://wp-types.com/foru…
// Overwrite Toolset Bootstrap parent theme widget arrays, see https://gist.github.com/Willem-Siebe/b8d8c048c979976b8d63.
function wpbootstrap_register_sidebar() {
register_sidebar(array(
'name' => __('Sidebar', 'wpbootstrap'),
'id' => 'sidebar',
@Willem-Siebe
Willem-Siebe / functions.php
Created June 13, 2014 14:34
Register new sidebar.
// Register new sidebar, see https://gist.github.com/Willem-Siebe/212a11e40442c38f20a2.
function wsis_register_sidebar_footer_widgets_top() {
register_sidebar(array(
'name' => __('Footer widgets top', 'wpbootstrap'),
'id' => 'footer-widgets-top',
@Willem-Siebe
Willem-Siebe / functions.php
Last active August 29, 2015 14:02
Loads the Facebook JavaScript asynchronously. I add this to my WordPress right after the body tag as suggested by Facebook here: https://developers.facebook.com/docs/plugins/like-box-for-pages (Include the JavaScript SDK on your page once, ideally right after the opening <body> tag.). For some reason Facebook does not offer asynchronously loadin…
// Add Facebook Javascript to your website, see https://gist.github.com/Willem-Siebe/9f5580bbe26991e2619c.
function wsis_add_facebook_script() {
?>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.async=true; js.src = "//connect.facebook.net/nl_NL/sdk.js#xfbml=1&appId=xxxxxxxxxxxxxxxxxxxx&version=v2.0";
@Willem-Siebe
Willem-Siebe / theme.js
Last active August 29, 2015 14:02
Toggling content using Twitter Bootstrap (V3) classes and jQuery, see also my answer here: http://stackoverflow.com/a/24338835/2312234.
// Toggling content using Twitter Bootstrap (V3) and jQuery, see https://gist.github.com/Willem-Siebe/d04636bb5eb42b28cdab.
jQuery(document).ready(function() {
jQuery(".wsis-toggle").click(function(){
jQuery(".wsis-collapse").toggle().toggleClass( "hidden show" );
});
});
@Willem-Siebe
Willem-Siebe / functions.php
Last active August 29, 2015 14:02
Adding Masonry Library to your WordPress (child) Theme, from WP 3.9, http://make.wordpress.org/core/2014/03/27/masonry-in-wordpress-3-9/. Tutorial: http://www.wpbeginner.com/wp-themes/how-to-use-masonry-to-add-pinterest-style-post-grid-in-wordpress/. Interesting: Also note that we are not adding jQuery as a dependency for either. One of the adva…
// Adding Masonry Library to your WordPress (child) Theme, see https://gist.github.com/Willem-Siebe/58e22d515087f1bba7aa.
// WSIS: Only use 'if' if you implement it in a parent theme.
if (! function_exists('wsis_slug_scripts_masonry') ) {
function wsis_slug_scripts_masonry() {
// WSIS: Add conditional tags here to only load it on specific pages.
wp_enqueue_script('masonry');
wp_enqueue_style('masonry-init', get_stylesheet_directory_uri().'/css/masonry.css');
}
@Willem-Siebe
Willem-Siebe / functions.php
Last active August 29, 2015 14:02
Initialize Masonry Javascript. jQuery should not be neseccary, see http://www.wpbeginner.com/wp-themes/how-to-use-masonry-to-add-pinterest-style-post-grid-in-wordpress/. However the code there does not work. Used jQuery from: http://zoerooney.com/blog/tutorials/qa-the-pinterest-style-grid-a-k-a-masonry/. Use options what is best for you, see: ht…
// Initialize Masonry Javascript, see https://gist.github.com/Willem-Siebe/e1096df4ad303b90ad1c.
function wsis_slug_masonry_init() {
if ( is_tax() || is_front_page() || is_search() ) {
?>
<script>
jQuery(document).ready(function($){
var $container = $("#wsis-wc-product-loop");
// initialize Masonry after all images have loaded
$container.imagesLoaded( function() {
@Willem-Siebe
Willem-Siebe / functions.php
Last active July 9, 2017 13:36
Display WooCommerce shop, category and tag description also on next pages. I can only changing it by declaring the same function name in my own functions.php, so that is what I did.
// Display WooCommerce shop, category and tag description also on next pages, see https://gist.github.com/Willem-Siebe/c883eeb2eefb5eea82ab.
function woocommerce_product_archive_description() {
if ( is_post_type_archive( 'product' ) && get_query_var( 'paged' ) >= 0 ) {
$shop_page = get_post( wc_get_page_id( 'shop' ) );
if ( $shop_page ) {
$description = apply_filters( 'the_content', $shop_page->post_content );
if ( $description ) {
echo '<div class="page-description">' . $description . '</div>';
}