Skip to content

Instantly share code, notes, and snippets.

View zeshanshani's full-sized avatar
🎯
Focusing

Zeshan Ahmed zeshanshani

🎯
Focusing
View GitHub Profile
@zeshanshani
zeshanshani / gravityforms-create-coupon-example.php
Created November 18, 2022 21:25
This function allows you to programatically create GravityForms coupon.
<?php
function zawp_create_coupon_codes() {
if ( isset( $_GET['create_coupons'] ) ) {
$coupons = array(
array(
'coupon_name' => 'Agnieszka K - OCC - SML client code 100€ OFF',
'coupon_code' => 'AgnieszkaK100',
'amount' => '100',
'type' => 'flat',
jQuery(document).ready(function($) {
$(document).on('keyup', function(e) {
if ( $('.lightbox').is(':visible') ) {
if ( e.which === 37 ) {
$('.gallery_prev').trigger('click');
} else if ( e.which === 39 ) {
$('.gallery_next').trigger('click');
}
}
})
@zeshanshani
zeshanshani / url-functions.js
Last active August 18, 2021 14:36
These functions include inserting a URL parameter, getting value from a URL parameter, and parsing query string
/**
* Insert Parameter in URL
*
* Dynamically insert or update a parameter in the URL.
*
* @param {string} key parameter name
* @param {string} value parameter value
* @param {string} base set a custom URL base.
* @param {boolean} historyUpdate defines if it update the URL without reloading the page
*/
<?php
/**
* Convert String to ID
*
* @param string $string
* @return string
*/
function zawp_convert_to_id( $string ) {
// Lower case everything
@zeshanshani
zeshanshani / side-popup.html
Created March 9, 2020 17:29
Side Popup that hides on scroll as you past down the #section-1 or whatever offset element you set.
<div class="side-popup">
<div class="side-popup__inner aos-init aos-animate" data-aos="fade-left" data-aos-easing="ease-out" data-aos-duration="1000" data-aos-delay="500">
<h4>Some Heading Goes Here</h4>
<a href="#" class="side-popup__cta button button--primary" target="">CTA Button Text</a>
</div>
</div>
<?php
/**
* GravityForms Change Submit Input to Button
*
* @param array $button
* @param array $form
* @return string
*/
add_filter( 'gform_submit_button', 'gform_submit_button', 10, 2 );
/**
* Set Cookie
*
* @param name name of the cookie
* @param value value of the cookie
* @param days days for the cookie
*/
function setCookie( name, value, days ) {
var expires = "";
if ( days ) {
// Usage: m-0 to m-7
// Usage: p-0 to p-7
// Usage: mb-0 to mb-7
$sizeUnit: rem;
$marginKey: 'm';
$paddingKey: 'p';
$separator: '-';
$sizes: (
('0', 0),
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce( func, wait, immediate ) {
var timeout;
return function () {
var context = this,
args = arguments;
var later = function () {
@zeshanshani
zeshanshani / mapOrder.js
Created May 2, 2019 21:30 — forked from ecarter/mapOrder.js
Order an array of objects based on another array order
/**
* Sort array of objects based on another array
*/
function mapOrder (array, order, key) {
array.sort( function (a, b) {
var A = a[key], B = b[key];