Skip to content

Instantly share code, notes, and snippets.

View maximejobin's full-sized avatar

Maxime Jobin maximejobin

View GitHub Profile
<?php
/*
################### READ ME #################################
You'll pass the URL to your feed/file to this function inside the "Download from URL" option when creating an import.
Image examples: https://d.pr/hCfNek and https://d.pr/MnerNb.
1. [custom_file_download("ftp://username:password@hostname.com/full/path/to/file.csv","csv")]
2. [custom_file_download("http://example.com/full/path/to/file.csv","csv")]
@jchristopher
jchristopher / gist:fc1d461bd82b40e31290
Last active August 30, 2019 18:45
Tell SearchWP to extract PDF contents of a file uploaded to an ACF file upload field and store that content with the post itself as custom metadata, not the Media entry
<?php
/**
* Extract PDF content from a file uploaded via ACF File field (where
* the actual data stored is only the Media ID) and store PDF
* content as SearchWP 'extra' metadata so it can be included in
* searches and attributed to the post itself, not the Media entry
*/
class My_SearchWP_Customizations {
@a-vasyliev
a-vasyliev / example.com.conf
Created March 25, 2015 11:42
Nginx: proxy cache without utm_* parameters (remove query parameter, remove utm tags nginx)
server {
listen 443;
server_name example.com;
error_log /var/log/nginx/example_com_error.log warn;
ssl on;
ssl_certificate /etc/nginx/ssl/your.crt; #certificate chains
ssl_certificate_key /etc/nginx/ssl/your.key; #private key
@amdrew
amdrew / gist:11197579
Last active October 18, 2022 23:03
Easy Digital Downloads - redirect when cart is empty
<?php
function sumobi_edd_empty_cart_redirect() {
$cart = function_exists( 'edd_get_cart_contents' ) ? edd_get_cart_contents() : false;
$redirect = site_url( 'shop' ); // could be the URL to your shop
if ( function_exists( 'edd_is_checkout' ) && edd_is_checkout() && ! $cart ) {
wp_redirect( $redirect, 301 );
exit;
}
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 17, 2024 02:53
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@alexjs
alexjs / cors-nginx.conf
Created November 28, 2012 22:42 — forked from michiel/cors-nginx.conf
Slightly tighter CORS config for nginx
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
@nb
nb / class-query-iterator.php
Created November 12, 2012 15:34
WordPress Chunk Query Iterators
<?php
/**
* Iterates over results of a query, split into many queries via LIMIT and OFFSET
*/
class QueryIterator implements Iterator {
var $limit = 500;
var $query = '';
var $global_index = 0;
@perusio
perusio / gist:1326701
Created October 31, 2011 01:28
Mobile device detection in Nginx with just 7 lines of configuration
### Testing if the client is a mobile or a desktop.
### The selection is based on the usual UA strings for desktop browsers.
## Testing a user agent using a method that reverts the logic of the
## UA detection. Inspired by notnotmobile.appspot.com.
map $http_user_agent $is_desktop {
default 0;
~*linux.*android|windows\s+(?:ce|phone) 0; # exceptions to the rule
~*spider|crawl|slurp|bot 1; # bots
~*windows|linux|os\s+x\s*[\d\._]+|solaris|bsd 1; # OSes