Skip to content

Instantly share code, notes, and snippets.

@Stanback
Stanback / nginx.conf
Last active March 30, 2025 03:57 — forked from michiel/cors-nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@spivurno
spivurno / gw-gravity-forms-calculated-shipping.php
Last active November 19, 2021 16:51
Gravity Wiz // Gravity Forms // Calculated Shipping
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-calculated-shipping.php
*/
/**
* Gravity Wiz // Gravity Forms // Calculated Shipping
*
* A simple method for using a calculated product field as a shipping field. This provides the ability to use
@wkw
wkw / jqChangeElementType.js
Last active May 30, 2020 05:04
jQuery Change Element Type usage: $("span").changeElementType("div")
// from Andrew Whitaker and Jazzbo, http://stackoverflow.com/a/15554920/161625
$.fn.changeElementType = function(newType) {
var newElements = [];
$(this).each(function() {
var attrs = {};
$.each(this.attributes, function(idx, attr) {
attrs[attr.nodeName] = attr.nodeValue;
});
@Shelob9
Shelob9 / 1-pods-loop-general-example.php
Last active April 9, 2025 15:01
Pods Looping Examples.
<?php
//set up pods::find parameters to limit to 5 items
$param = array(
'limit' => 5,
);
//create pods object
$pods = pods('pod_name', $params );
//check that total values (given limit) returned is greater than zero
if ( $pods->total() > 0 ) {
@Shelob9
Shelob9 / ships.php
Last active April 4, 2020 21:25
Example code for my Pods Screencast: Using Pods Pages With Advanced Content Types -- http://youtu.be/iUDPYid0bUU
<?php
/**
* Template Name: Ships
*/
get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php
# Basic Usage
new GW_List_Field_As_Choices( array(
'form_id' => 1,
'list_field_id' => 2,
'choice_field_ids' => 3
) );
# Enable Sorting of Choices Alphanumerically
@ChromeOrange
ChromeOrange / gist:8287925
Last active February 25, 2020 04:22
Delete all tax rates from WooCommerce
/**
* Delete ALL WooCommerce tax rates
*
* Add to your theme functions.php then go to woocommerce -> system status -> tools and there will be a delete all tax rates button http://cld.wthms.co/tXvp
*/
add_filter( 'woocommerce_debug_tools', 'custom_woocommerce_debug_tools' );
function custom_woocommerce_debug_tools( $tools ) {
$tools['woocommerce_delete_tax_rates'] = array(
@jmwhittaker
jmwhittaker / gist:8516514
Last active December 13, 2024 21:09
Use FFmpeg to resize and generate .mp4 & .webm videos from any source video.
/**
Scaling
- Scale can be used as is which will set the height to 560 but keep aspect ratio for width.
- Other options include setting both with & height
- Watch out for sizing errors when not divisible by 2
**/
/** MP4 1st pass **/
ffmpeg -i input.mov -vcodec libx264 -vprofile high -preset veryslow -b:v 225k -maxrate 300k -bufsize 1000k -vf scale=-1:560 -threads 2 -pass 1 -an -f mp4 /dev/null
@joshmoto
joshmoto / functions.php
Created February 4, 2014 13:11
Media Filter function (page, download, reports, (all post types))
<?php
/* MEDIA LIBRARY FILTER */
add_filter('parse_query', 'node_admin_posts_filter');
add_action('restrict_manage_posts', 'node_admin_posts_filter_restrict_manage_posts');
function node_admin_posts_filter($wp_query)
{
if (is_admin() && isset($_GET['page_id']) && $_GET['page_id'] != '')
{
$original_query = $wp_query;