Skip to content

Instantly share code, notes, and snippets.

View sabbiseaan's full-sized avatar
🕷️
I may be slow to respond.

sabbiseaan

🕷️
I may be slow to respond.
View GitHub Profile
function scrollAnimated(to, duration) {
var start = $(window).scrollTop(),
change = to - start,
currentTime = 0,
increment = 20;
function easeInOut(currentTime, startValue, change, duration) {
currentTime /= duration / 2;
if (currentTime < 1) {
@sabbiseaan
sabbiseaan / debounce.js
Created November 8, 2019 04:23 — forked from vctrfrnndz/debounce.js
Debounce
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
@sabbiseaan
sabbiseaan / umd-script-boilerplate.js
Created October 23, 2019 13:20 — forked from cferdinandi/umd-script-boilerplate.js
A simple boilerplate for UMD JS modules.
(function (root, factory) {
if ( typeof define === 'function' && define.amd ) {
define([], factory(root));
} else if ( typeof exports === 'object' ) {
module.exports = factory(root);
} else {
root.myPlugin = factory(root);
}
})(typeof global !== "undefined" ? global : this.window || this.global, function (root) {
@sabbiseaan
sabbiseaan / ThzelGetElementSettings.php
Created July 29, 2019 04:48 — forked from danyj/ThzelGetElementSettings.php
Pull any Elementor options outside of Elementor
/**
* @package Thz Framework
* @author Themezly
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
* @websites http://www.themezly.com | http://www.youjoomla.com | http://www.yjsimplegrid.com
*/
class ThzelGetElementSettings {
@sabbiseaan
sabbiseaan / one-theme-two-textdomains.php
Created July 17, 2019 05:56 — forked from justintadlock/one-theme-two-textdomains.php
How one theme can have two textdomains and still work with translation systems.
<?php
/**
* The purpose of this file is to show how a theme can have multiple textdomains
* and still work with a single translation file. Translation tools like the
* one used on WordPress.org and Poedit are going to simply scan the project for
* text strings, regardless of the textdomain (and for good reasons that are
* not relevant here).
*
* The code below works with that system. It assumes that we have a single MO
* file based on the theme's textdomain. So, how can two textdomains work? It
// multi condition check. help from: elementor pro > price-list.php > search by(image_spacing)
// content style section option
$this->start_controls_section(
'wpb_ea_post_item_content_style_options',
[
'label' => __( 'Content', 'your-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'.wpb_ea_post_carousel_content_options.wpb_ea_show_excerpt! + .wpb_ea_post_carousel_content_options.wpb_ea_read_more_btn!' => '',
],
@sabbiseaan
sabbiseaan / controls.php
Created June 27, 2019 17:25 — forked from bschulz87/controls.php
Elementor Custom Control
<?php
namespace ElementorControls;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class Elementor_Custom_Controls {
private static $_instance = null;
@sabbiseaan
sabbiseaan / regexCheatsheet.js
Created May 27, 2019 04:49 — forked from celsobessa/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
Here is my public file code
<?php
/**
* The public-facing functionality of the plugin.
*
* @link
* @since 1.0.0
*
* @package plugin_name
@sabbiseaan
sabbiseaan / add-to-cart.php
Created May 25, 2019 04:42 — forked from webaware/add-to-cart.php
WooCommerce purchase page add-to-cart with quantity and AJAX, by customising the add-to-cart template in the WooCommerce loop. See blog post for details: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
<?php
/**
* Loop Add to Cart -- with quantity and AJAX
* requires associated JavaScript file qty-add-to-cart.js
*
* @link http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
* @link https://gist.github.com/mikejolley/2793710/
*/
// add this file to folder "woocommerce/loop" inside theme