Skip to content

Instantly share code, notes, and snippets.

@awran5
awran5 / CMB2 range input.md
Last active October 23, 2018 22:27
Basic CMB2 slider field based on HTML5 range input

This originally was based on slider field

I've changed its structure to avoid loading of heavy jquery UI so its only used the basic HTML5 type range input

1. php Filter

function cmb2_render_range( $field, $field_escaped_value, $field_object_id, $field_object_type, $field_type_object ){

  $slider = $field_type_object->input( array(
    'type'  => 'range',
@pauloiankoski
pauloiankoski / gist:78a94ae0c11ad15dac9c
Created January 14, 2016 00:00
WooCommerce Ajax Cart Update
jQuery(document).ready(function($){
var woocommerce_form = $( '.woocommerce-cart form' );
woocommerce_form.on('change', '.qty', function(){
form = $(this).closest('form');
// emulates button Update cart click
$("<input type='hidden' name='update_cart' id='update_cart' value='1'>").appendTo(form);
// get the form data before disable button...
formData = form.serialize();
@ms-studio
ms-studio / add-term-to-custom-taxonomy.php
Created December 15, 2015 08:10
add term metabox to custom taxonomy - using WP 4.4 term meta functions
<?php
// source: http://wordpress.stackexchange.com/questions/211703/need-a-simple-but-complete-example-of-adding-metabox-to-taxonomy
// code authored by jgraup - http://wordpress.stackexchange.com/users/84219/jgraup
// CREATE CUSTOM TAXONOMY
add_action( 'init', '___create_my_custom_tax' );
@bekarice
bekarice / wc-require-cat-minimum.php
Created December 9, 2015 08:00
WooCommerce Require Category Minimum for Purchase
<?php
/**
* only copy the opening php tag if needed
* tutorial at: http://swwp.co/6l
*/
/**
* Renders notices and prevents checkout if the cart
* does not contain a minimum number of products in a category
*/
@james2doyle
james2doyle / render-php-file.php
Last active April 4, 2024 15:33
A function to render a php file with data. Allows templating and then sending an array of data into the view.
<?php
function renderPhpFile($filename, $vars = null) {
if (is_array($vars) && !empty($vars)) {
extract($vars);
}
ob_start();
include $filename;
return ob_get_clean();
}
@helen
helen / repeatable-fields-metabox.php
Created January 11, 2012 04:42
Repeating Custom Fields in a Metabox
<?
/**
* Repeatable Custom Fields in a Metabox
* Author: Helen Hou-Sandi
*
* From a bespoke system, so currently not modular - will fix soon
* Note that this particular metadata is saved as one multidimensional array (serialized)
*/
function hhs_get_sample_options() {