Skip to content

Instantly share code, notes, and snippets.

View zeshanshani's full-sized avatar
🎯
Focusing

Zeshan Ahmed zeshanshani

🎯
Focusing
View GitHub Profile
<?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];
body .gform_wrapper .gform_footer {
padding-bottom: 0;
}
@media screen and (min-width: 768px) {
body .gform_wrapper .gform_footer {
text-align: right;
}
}
@zeshanshani
zeshanshani / imgPrint.js
Created March 12, 2019 09:24
This code prints an image on the page.
/**
* Image Sourec to Print
*
* Usage:
*
* imgPrint( $('img').attr('src') );
*
* @param {string} source source of the image
*/
function imgSourceToPrint( source ) {
@zeshanshani
zeshanshani / copy-to-clipboard.js
Created March 10, 2019 21:16
This function allows you to copy a string to the clipboard.
/**
* Copy Text to Clipboard
*
* Usage: simply pass the string to copyToClipboard() funciton and it will be
* copied to the clipboard
*
* Source: https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f
*/
function copyToClipboard( str ) {
const el = document.createElement('textarea'); // Create a <textarea> element
<?php // Do not copy this line.
/**
* Remove Script Version
*
* This function removes the query string from the scripts and styles.
*
* Author: Zeshan Ahmed
* Author URI: https://zeshanahmed.com/
*
@zeshanshani
zeshanshani / is_external.php
Created March 9, 2019 08:23
This function checks if the provided URL is of external site or not. Returns boolean.
<?php // do not copy this line.
/**
* Is External
*
* This function checks if the provided URL is external or not.
*
* Author URL: https://zeshanahmed.com/
*