Skip to content

Instantly share code, notes, and snippets.

View consciousimages's full-sized avatar

consciousimages

View GitHub Profile
@offroadkev
offroadkev / functions.php
Created July 20, 2018 22:05
Change Gravity Forms Spinner to CSS Spinner
// Changes Gravity Forms Ajax Spinner (next, back, submit) to a transparent image
// this allows you to target the css and create a pure css spinner like the one used below in the style.css file of this gist.
add_filter( 'gform_ajax_spinner_url', 'spinner_url', 10, 2 );
function spinner_url( $image_src, $form ) {
return 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; // relative to you theme images folder
}
@bdaley
bdaley / wc-regenerate-and-notify.php
Last active July 28, 2021 00:02
Adds an action to the order page that allows you to regenerate download permissions AND extends the expiration date for WooCommerce downloads.
<?php
add_filter('woocommerce_order_actions', 'wc_regenerate_and_notify_custom_order_action');
function wc_regenerate_and_notify_custom_order_action( $actions ) {
// Remove the woocommerce option to regenerate to avoid confusion
unset($actions['regenerate_download_permissions']);
// Add our new action (executed below)
$actions['wc_regenerate_and_notify'] = __('Regenerate permissions & send link to customer', 'wc-regenerate-and-notify');
return $actions;
@paulirish
paulirish / what-forces-layout.md
Last active June 26, 2024 20:47
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@carcinocron
carcinocron / debugger pause beforeunload
Last active April 25, 2024 16:48
Chrome: pause before redirect
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { debugger; }, false)
@eriteric
eriteric / movegfjstofooter.php
Last active October 13, 2021 16:55
Load gravity forms JS in footer
// GF method: http://www.gravityhelp.com/documentation/gravity-forms/extending-gravity-forms/hooks/filters/gform_init_scripts_footer/
add_filter( 'gform_init_scripts_footer', '__return_true' );
// solution to move remaining JS from https://bjornjohansen.no/load-gravity-forms-js-in-footer
add_filter( 'gform_cdata_open', 'wrap_gform_cdata_open' );
function wrap_gform_cdata_open( $content = '' ) {
$content = 'document.addEventListener( "DOMContentLoaded", function() { ';
return $content;
}
add_filter( 'gform_cdata_close', 'wrap_gform_cdata_close' );
@xdamman
xdamman / install_ffmpeg_ubuntu.sh
Created July 2, 2014 21:03
Install latest ffmpeg on ubuntu 12.04 or 14.04
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
@hdragomir
hdragomir / sm-annotated.html
Last active June 13, 2024 03:01
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@maxrice
maxrice / gist:6541634
Last active April 23, 2020 18:11
WooCommerce - sort the cart alphabetically by the product's title
<?php
add_action( 'woocommerce_cart_loaded_from_session', function() {
global $woocommerce;
$products_in_cart = array();
foreach ( $woocommerce->cart->cart_contents as $key => $item ) {
$products_in_cart[ $key ] = $item['data']->get_title();
}
@elclanrs
elclanrs / email-confirmation.php
Last active July 26, 2022 00:11
Simple e-mail confirmation plugin for WordPress.
<?php
/**
* Plugin Name: Email Confirmation
* Description: Send an email to the user with confirmation code and store form data in database until user confirms.
* Author: Cedric Ruiz
*/
class EmailConfirmation
{
const PREFIX = 'email-confirmation-';
@ChrisCree
ChrisCree / gist:5888660
Last active March 15, 2018 22:55
Genesis doesn't put a page title on the blog page template by default. Here's a a function that will do that for you. Just drop it into your functions.php file.
<?php
// Don't copy the opening <?php tag above
// Add page title to blog page template
add_action( 'genesis_before', 'wsm_blog_page_title' );
function wsm_blog_page_title() {
if ( is_page_template( 'page_blog.php' ) ) {
add_action( 'genesis_before_content', 'wsm_show_blog_page_title_text', 2 );
}
}