Skip to content

Instantly share code, notes, and snippets.

;(function ($, window) {
var intervals = {};
var removeListener = function(selector) {
if (intervals[selector]) {
window.clearInterval(intervals[selector]);
intervals[selector] = null;
}
<?
/**
* 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() {
@goranefbl
goranefbl / wysiwyg-meta-box.php
Last active April 20, 2016 06:26 — forked from retgef/wysiwyg-meta-box.php
How to add a Wordpress WYSIWYG editor to a meta box.
<?php
define('WYSIWYG_META_BOX_ID', 'my-editor');
define('WYSIWYG_EDITOR_ID', 'myeditor'); //Important for CSS that this is different
define('WYSIWYG_META_KEY', 'extra-content');
add_action('admin_init', 'wysiwyg_register_meta_box');
function wysiwyg_register_meta_box(){
add_meta_box(WYSIWYG_META_BOX_ID, __('WYSIWYG Meta Box', 'wysiwyg'), 'wysiwyg_render_meta_box', 'post');
}
// Not Working for Defaults
vc_map(array(
"name" => __("Google Map Holder", "js_composer") ,
"icon" => YES_ADDON_ASSETS_URL ."images/yes-icon.png",
"weight" => 21,
"base" => "map_holder",
"description" => __("Add all locations inside this container", "js_composer") ,
"as_parent" => array(
'only' => 'map_location'
) ,
/**
* Dropdown(select with options) shortcode attribute type generator.
*
* @param $settings
* @param $value
*
* @since 4.4
* @return string - html string.
*/
@goranefbl
goranefbl / custom-woocommerce-shipping.php
Last active September 5, 2023 16:20
Adds a new shipping method that calculates shipping price based on quantity of products
<?php
/*
Plugin Name: Shipping Price per Quantity Plugin
Plugin URI: http://itsgoran.com
Description: Adds a new shipping method that calculates shipping price based on quantity of products - made for Cider.
Version: 1.0.0
Author: Goran Jakovljevic
Author URI: http://itsgoran.com
*/
@goranefbl
goranefbl / gist:6f370cc3bef3601e3df8
Last active October 7, 2015 05:58
Cookie GET example
(function( $ ) {
'use strict';
//Javascript GET cookie parameter
var $_GET = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
function decode(s) {
return decodeURIComponent(s.split("+").join(" "));
}
@goranefbl
goranefbl / gist:c042fa44edd9e88434f0
Created October 7, 2015 13:18
Add quantity to the archive page
add_action( 'woocommerce_after_shop_loop_item', 'my_custom_quantity_field', 9 );
function my_custom_quantity_field() {
global $product;
if ( ! $product->is_sold_individually() )
woocommerce_quantity_input( array(
'min_value' => apply_filters( 'woocommerce_quantity_input_min', 1, $product ),
'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product )
) );
}
@goranefbl
goranefbl / gist:6cfda8683069b16eaeb6
Created October 7, 2015 14:13
Woocommerce Shortcodes
<?php
/**
* Shortcodes init
*
* Init main shortcodes, and add a few others such as recent products.
*
* @author WooThemes
* @category Shortcodes
* @package WooCommerce/Shortcodes
* @version 1.6.4
@goranefbl
goranefbl / custom.js
Created October 21, 2015 15:35
Owl Slider Image as Background Image
$(document).ready(function() {
$("#owl-demo").owlCarousel({
navigation : true,
slideSpeed : 300,
paginationSpeed : 400,
singleItem : true,
afterInit: afterOWLinit
});