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 / dark-mode-favicon.js
Last active September 18, 2020 23:19
Dark mode favicon
/**
* HTML Markup to place in your <head> tag
* <link rel="icon" type="image/png" href="/favicon.png" data-dark="/favicon-dark.png" />
*/
// Attach listener to DOM Loaded
window.addEventListener( 'DOMContentLoaded', setFavicon );
// Set specific favicon if browser is in dark mode
function setFavicon() {
@Bobz-zg
Bobz-zg / gravity-forms-mods.php
Last active June 6, 2019 09:10
Change Gravity Forms submit input to button element
<?php
/**
* Change submit form <input> element to <button> element for AJAX enabled forms
*
* @link https://docs.gravityforms.com/gform_submit_button/
*/
add_filter( 'gform_submit_button', function ( $button, $form ) {
$dom = new DOMDocument();
@Bobz-zg
Bobz-zg / youtube.js
Created February 18, 2019 14:57
Make youtube iframe api work in tabs / carousel on show
/**
* My markup for video is generated with PHP and it looks like this:
*
* foreach ( $videoURLs as $video_url ) :
*
* Need to get only video_id param from URL, something like: dEy6mu0UarM
*
* $video_id = explode('=', $video_url);
*
*
@Bobz-zg
Bobz-zg / functions.php
Last active January 30, 2019 03:06
Remove 'Category' from 'Quick edit' screen in WordPress admin
<?php
/**
* Filters whether the current taxonomy should be shown in the Quick Edit panel.
*
* @since 4.2.0
*
* @param bool $show_in_quick_edit Whether to show the current taxonomy in Quick Edit.
* @param string $taxonomy_name Taxonomy name.
@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',
@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
*/
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');
/**
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');
@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' );
});