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() {
/**
* Dropdown(select with options) shortcode attribute type generator.
*
* @param $settings
* @param $value
*
* @since 4.4
* @return string - html string.
*/
@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 / 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
});
public function ttr_container( $content ) {
$custom_content = '';
if(0 == 0) {
ob_start();
$this->social_share();
$custom_content .= ob_get_contents();
ob_end_clean();
}
$custom_content .= '<div class="ttr_start"></div>';
$custom_content .= $content;
@goranefbl
goranefbl / plugin.php
Created November 26, 2015 18:42 — forked from kevinwhoffman/plugin.php
Dependent Plugin Activation/Deactivation and Alert
<?php
/*
* Dependent Plugin Activation/Deactivation
*
* Sources:
* 1. https://pippinsplugins.com/checking-dependent-plugin-active/
* 2. http://10up.com/blog/2012/wordpress-plug-in-self-deactivation/
*
*/
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
window.fbAsyncInit = function() {
FB.init({
appId : 'app_id',
// 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'
) ,