Skip to content

Instantly share code, notes, and snippets.

@wpconsulate
wpconsulate / ajax-cart.js
Created December 13, 2023 23:43 — forked from marioloncarek/ajax-cart.js
complete shopify ajax cart solution with drawer and modal, adding and removing products - ugly AF
const defaults = {
cartModal: '.js-ajax-cart-modal', // classname
cartModalContent: '.js-ajax-cart-modal-content', // classname
cartModalClose: '.js-ajax-cart-modal-close', // classname
cartDrawer: '.js-ajax-cart-drawer', // classname
cartDrawerContent: '.js-ajax-cart-drawer-content', // classname
cartDrawerClose: '.js-ajax-cart-drawer-close', // classname
cartDrawerTrigger: '.js-ajax-cart-drawer-trigger', // classname
cartOverlay: '.js-ajax-cart-overlay', // classname
cartCounter: '.js-ajax-cart-counter', // classname
@wpconsulate
wpconsulate / MySQL_5.7_macOS-Big_Sur.md
Created January 9, 2021 22:01
Install MySql 5.7 on MacOS Big Sur

This is a fork of original gist https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e, with slight changes on pointing to 5.7 version branch, instead of 8 (latest default of MySQL in Hombrew).

Install MySQL 5.7 on macOS

This procedure explains how to install MySQL using Homebrew on macOS (Sierra 10.12 and up)

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.
// Example POST method implementation:
async function postData(url = '', data = {}) {
// Default options are marked with *
const response = await fetch(url, {
method: 'POST', // *GET, POST, PUT, DELETE, etc.
mode: 'cors', // no-cors, *cors, same-origin
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
credentials: 'same-origin', // include, *same-origin, omit
headers: {
'Content-Type': 'application/json'
<?php
define( 'CC_API_VER', '3');
define( 'CC_API_KEY', 'CC_KEY_HERE');
define( 'CC_API_SECRET', 'SECRET HERE');
define( 'CC_CREDS_FILE', dirname(__FILE__) .'/cccreds.json' );
define( 'CC_REDIRECT_URI', 'https://abbalist.org/service-listings' );
define( 'CC_REFRESH_INTERVAL', 60*60*2 ); // In seconds 60 seconds * 60 Mins * 24 hours
define( 'CC_POPUP_TIMEOUT', 30 ); // In secnods
if( ! function_exists('pr') ){
.parallux,.parallux.no-parallax .parallux-bg{position:relative}.parallux.no-parallax,.parallux.not-full{overflow:hidden}.parallux .parallux-bg,.parallux .parallux-bg .parallux-inner{top:0;left:0;-webkit-backface-visibility:hidden;-webkit-perspective:1000}body,html{height:100%}.parallux.not-full .parallux-bg{height:100%;bottom:initial}.parallux.no-parallax .parallux-bg,.parallux.no-parallax .parallux-inner{background-attachment:initial}.parallux.bg-fixed .parallux-inner{background-attachment:fixed}.parallux .parallux-bg{right:0;height:100%;overflow:hidden;position:fixed}.parallux .parallux-bg .parallux-inner{position:relative;min-width:100%;min-height:100%;height:auto;background-color:#fff;background-repeat:no-repeat;background-position:50%;background-size:cover;background-image:url()}.parallux .parallux-bg .parallux-inner img{max-width:100%;max-height:100%;display:none}.parallux .parallux-bg .parallux-inner.dark-1{background-color:#084550}.parallux .parallux-bg .parallux-inner.dark-2{background-color:#292A31}
/*!
* Responsive jQuery Parallax plugin
* Original author: @tomsarduy
* Licensed under the MIT license
*/
// the semi-colon before the function invocation is a safety
// net against concatenated scripts and/or other plugins
// that are not closed properly.
;(function ( $, window, document, undefined ) {
@wpconsulate
wpconsulate / mobileAndTabletCheck.js
Created May 12, 2020 00:54
Here's a function that uses an insanely long and comprehensive regex which returns a true or false value depending on whether or not the user is browsing with a mobile.
// For those wishing to include tablets in this test (though arguably, you shouldn't), you can use the following function:
window.mobileAndTabletCheck = function() {
let check = false;
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\
@wpconsulate
wpconsulate / get-order-info.txt
Created April 30, 2020 01:52
WooCommerce: Get Order Info (total, items, etc) from $order Object
1. You have access to $order variable
Hooks (do_action and apply_filters) use additional arguments which are passed on to the function. If they allow you to use the “$order” object you’re in business. Here’s how to get all the order information:
// Get Order ID and Key
$order->get_id();
$order->get_order_key();
// Get Order Totals $0.00
$order->get_formatted_order_total();
$order->get_cart_tax();
<?php
class WP_REST_API_Sample extends WP_REST_Controller {
function __construct(){
add_action( 'rest_api_init', array($this, 'register_routes') );
}
/**
* Register the routes for the objects of the controller.
@wpconsulate
wpconsulate / customplugin.php
Last active March 11, 2020 09:37
Wordpress Activation Email Subject + Contents Update
<?php
/*
* Change the Subject of the Email Confirmation Email sent to user
*/
add_filter ( 'wppb_signup_user_notification_email_subject', 'wppbc_custom_email_confirmation_subject', 20, 8 );
function wppbc_custom_email_confirmation_subject($subject, $user_email, $user, $activation_key, $registration_page_url, $meta, $from_name, $context ){
// $default_message = sprintf( __( '[%1$s] Activate %2$s', 'profile-builder'), $from_name, $user );
$new_message = sprintf( __( '[%1$s] Activate your account', 'profile-builder'), $from_name);
return $new_message;