Skip to content

Instantly share code, notes, and snippets.

@sosroInSpace
sosroInSpace / google-sheet-php.json
Created February 18, 2021 08:01
send data from wordpress to google sheet via php
<?php
// TODO: validate input params, ignore bots...
require_once("../../../../wp-load.php");
require __DIR__ . '/vendor/autoload.php'; // google-api-php-client path
$plugin_list = get_plugins();
$output = "";
foreach($plugin_list as $item) {
@sosroInSpace
sosroInSpace / submit_sheet.js
Last active May 26, 2020 03:39
Generic Google Sheet Form Submission Function (jquery)
// google sheet form submission
function submit_sheet(submit_button,the_form,sheet,success_message,success_show){
// onclick of form submit button
jQuery(submit_button).click(function(e){
e.preventDefault();
// serialize form data
var form = jQuery(the_form).serialize();
alert(form);
@sosroInSpace
sosroInSpace / input_search.html
Created May 13, 2020 14:53
script to append multiple input drop down search.
<input type="text" class="spb-productdescfont">
<input type="text" class="spb-productdescfont">
<input type="text" class="spb-productdescfont">
<script>
$('.spb-productdescfont').append('<div class="search-bar"><input type="text" class="seeker"></div><div class="content"></div>')
var data = [
{"name":"clackercart",},{"name":"rocking horse",},{"name":"ringtoss",},{"name":"succulent plant",},{"name":"manhole cover",},{"name":"birdbath",},{"name":"birdhouse",},{"name":"tiki torch",},{"name":"acoustic guitar",},{"name":"grass standee",},{"name":"hedge standee",},{"name":"mountain standee",},{"name":"tree standee",},{"name":"wave breaker",},{"name":"ukulele",},{"name":"tall lantern",},{"name":"deer scare",},{"name":"boomerang",},{"name":"bamboo bench",},{"name":"hearth",},{"name":"garden rock",},{"name":"tall garden rock",},{"name":"tea table",},{"name":"mush lamp",},{"name":"mush table",},{"name":"birdcage",},{"name":"wooden bucket",},{"name":"holiday candle",},{"name":"fruit basket",},{"name":"
var data = [{"name":"clackercart",},{"name":"rocking horse",},{"name":"ringtoss",},{"name":"succulent plant",},{"name":"manhole cover",},{"name":"birdbath",},{"name":"birdhouse",},{"name":"tiki torch",},{"name":"acoustic guitar",},{"name":"grass standee",},{"name":"hedge standee",},{"name":"mountain standee",},{"name":"tree standee",},{"name":"wave breaker",},{"name":"ukulele",},{"name":"tall lantern",},{"name":"deer scare",},{"name":"boomerang",},{"name":"bamboo bench",},{"name":"hearth",},{"name":"garden rock",},{"name":"tall garden rock",},{"name":"tea table",},{"name":"mush lamp",},{"name":"mush table",},{"name":"birdcage",},{"name":"wooden bucket",},{"name":"holiday candle",},{"name":"fruit basket",},{"name":"pile of leaves",},{"name":"magazine rack",},{"name":"moon",},{"name":"music stand",},{"name":"rocking chair",},{"name":"outdoor bath",},{"name":"scarecrow",},{"name":"brick oven",},{"name":"swinging bench",},{"name":"tire stack",},{"name":"DIY workbench",},{"name":"pear wardrobe",},{"name":"barrel",
<!DOCTYPE html>
<html>
<!-- This file is a working version of the generic email template. -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
</head>
<body bgcolor="#F8F8F8" style="margin:0px; padding:0px; background-color:#f8f8f8;">
@sosroInSpace
sosroInSpace / spin-the-wheel.js
Last active February 27, 2024 07:39
Spin the wheel function - define chances of winning certain prizes
function spinTheWheel(personemail) {
// All possible results, with probabilities.
var results = [
{
name: 'YOU WON 30% OFF IN STORE!',
rot: 116,
description: 'use the discount code below at the shop checkout',
code: 'CODEONE',
@sosroInSpace
sosroInSpace / birthdateValidate.js
Last active May 5, 2019 09:05
Validate users birthdate to be at least 18 years old
/*--------------------------------------------------------------------------
VALIDATE BIRTH DATE TO BE ATLEAST 18 YEARS OLD
--------------------------------------------------------------------------*/
function validateBirthDate() {
// date formmat day/month/year = 23/02/2001
var dateValue = $('#customer_birth_date').val();
var dateInput = $('#customer_birth_date');
@sosroInSpace
sosroInSpace / api-call.html
Last active August 19, 2018 11:50
JSON NEWS API CALL
<style>
#news-result{text-align:center;width:50%;margin:auto;font-family:sans-serif;font-size:14px}.header-image{width:100%;height:150px;background-size:cover;background-position:center}#news-result a{display:inline-block;background:red;margin-bottom:50px;padding:8px 26px;color:#fdfdfd;text-decoration:none;text-transform:uppercase;font-size:12px}
</style>
<!-- results go here -->
<div id="news-result">
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
@sosroInSpace
sosroInSpace / multi_file_upload.php
Last active June 10, 2018 15:08
Basic Multiple file upload with array inserted into database
<style>
.message-confirm li {line-height: 260%;}.message-confirm {margin-bottom: 15px;position: absolute;top: 0;background: #fff;width: 50%;margin-left: 25%;min-height: 300px;z-index: 3;border: 2px solid;padding-top: 20px;animation-name:message-confirm;animation-iteration-count:1;animation-duration:.5s;animation-fill-mode:forwards;animation-timing-function:ease-in;margin-top:20px;}@-webkit-keyframes message-confirm {0%{margin-top:0;}100%{margin-top:20px;}}@keyframes message-confirm {0%{margin-top:0;}100%{margin-top:20px;}}.file_drag_to:hover,.file_input:hover,.flexor{cursor:pointer}body{padding-top:15px;padding-left:15px;padding-right:15px;margin:0;font-family:arial,sans-serif}.file_drag_to{width:100%;margin-top:15px;height:50%;background:#FFEB3B;border:2px solid #222;position:relative;transition:.5s}.file_input,.flexor{position:absolute;width:100%;height:100%}.the_green{background:#dcffb3!important;transition:.5s ease-in}.file_drag_to:hover{background:#fdfdfd;transition:.5s}.file_input{opacity:0}.flexor{top
@sosroInSpace
sosroInSpace / local_storage_modal_display.js
Last active April 11, 2018 09:15
Code for use with local storage - display modal once and then hide after submission with different css classes applied dependent on selected options.
if ($(window).width() < 768) {
//* if local storage is supported or not -->
if (typeof Storage !== "undefined") {
/* update variable -->*/
var keyName = 'hulc_hand';
/* store local storage item into variable -->*/
var hand = localStorage.getItem(keyName);