Skip to content

Instantly share code, notes, and snippets.

View Bobz-zg's full-sized avatar
👨‍💻
working remotely

Vlado Bosnjak Bobz-zg

👨‍💻
working remotely
View GitHub Profile
@Bobz-zg
Bobz-zg / debug-wpmail.php
Last active November 13, 2022 15:02
Debug wp_mail function. Display errors on screen
<?php
/**
* Display errors
*/
if ( ! function_exists('debug_wpmail') ) :
function debug_wpmail( $result = false ) {
if ( $result )
return;
@Bobz-zg
Bobz-zg / woo-actions.php
Created April 23, 2017 05:40
Enable Gallery in single product template in WooCommerce 3.0
<?php
/**
* WooCommerce 3.0 gallery fix
*/
add_action( 'after_setup_theme', function () {
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
});
@Bobz-zg
Bobz-zg / include-pp-woo-products.php
Last active February 27, 2017 16:16
Include password protected products in WooCommerce search results for non-logged in users
<?php
/**
* Place this part of code somewhere in functions.php
*/
add_filter( 'posts_where' , function($q) {
global $wpdb;
$r = "AND ({$wpdb->posts}.post_password = '')";
$q = str_replace($r, '', $q);
@Bobz-zg
Bobz-zg / wistia-video-click-to-play.js
Created January 20, 2017 04:15
Click to play Wistia Video via Javascript API
$('.play').click( function(event) {
if(event.preventDefault) { event.preventDefault(); }
$video = $(this).closest('iframe');
if ( $video.hasClass('wistia_embed') ) {
window._wq = window._wq || [];
$video_id = /[^/]*$/.exec( $video.attr('src') )[0];
@Bobz-zg
Bobz-zg / add-wistia-oembed-support.php
Created January 20, 2017 03:53
Adds support for oEmbed Wistia videos to WordPress
add_action( 'init', function () {
wp_oembed_add_provider( '/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/.*/', 'http://fast.wistia.net/oembed', true );
});
@Bobz-zg
Bobz-zg / woo-checkout.php
Last active April 12, 2023 01:41
Pre-populate Woocommerce checkout fields
<?php
/**
* Pre-populate Woocommerce checkout fields
* Note that this filter populates shipping_ and billing_ fields with a different meta field eg 'first_name'
*/
add_filter('woocommerce_checkout_get_value', function($input, $key ) {
global $current_user;
switch ($key) :
@Bobz-zg
Bobz-zg / toggle.html
Created September 9, 2016 16:28
Simple reusable toggle with jquery
<a href="#toggleMe" data-toggle="toggleMe">Toggle div</a>
<div id="toggleMe" class="toggler">
Content goes here ...
</div>
@Bobz-zg
Bobz-zg / toggler.css
Created September 9, 2016 16:00
Simple jquery toggle function Raw
.toggler {
overflow: hidden;
max-height: 0;
transition: max-height .3s ease-in;
}
.toggler.active {
max-height: 2000px;
transition: max-height .3s ease-out;
}
@Bobz-zg
Bobz-zg / toggler.jquery.js
Last active September 9, 2016 16:37
Simple jquery toggle function
$.fn.toggler = function() {
return this.each( function() {
$(this).click(function(event) {
// Prevent click event on a tag
if ($(this).is('a')) {
if(event.preventDefault) { event.preventDefault(); }
}
(function($) {
function triggerError($err, $status) {
$msg = false;
$errors = {
'e100' : "Something went wrong, please try again later",
'e101' : "Please enter you'r username and password",
'e102' : "Please enter you'r email",
'e103' : "Please populate all fields marked with *",