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 / 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 / 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 / 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 / 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 / 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 / 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;
const path = require('path');
const config = require('./config');
const webpack = require('webpack');
const merge = require('webpack-merge');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const config = require('./config');
const webpack = require('webpack');
const merge = require('webpack-merge');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const hotMiddlewareScript = require('webpack-hot-middleware');
/**
@Bobz-zg
Bobz-zg / wc-search-product-filter.php
Last active September 19, 2018 18:11
Filter videos products from product search JSON in wp-admin 'Woocommerce orders' view
<?php if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Filter Streaming videos products from JSON search in wp-admin 'Woocommerce orders' view
*/
add_filter( 'woocommerce_json_search_found_products', function( $products ) {
/**
* Check HTTP Referer
*/
@Bobz-zg
Bobz-zg / woo-template-parts-filter.php
Created October 12, 2018 09:30
Quickly unhook WooCommerce template parts
<?php
/**
* Remove variouse template parts in WooCommerce
*/
add_filter( 'wc_get_template', function( $located, $template_name, $args, $template_path, $default_path ) {
$remove = [
'sale-flash.php',
'meta.php',