Skip to content

Instantly share code, notes, and snippets.

View smarchal's full-sized avatar
🏕️
I may be slow to respond.

Sébastien Marchal smarchal

🏕️
I may be slow to respond.
View GitHub Profile
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@tvandervossen
tvandervossen / environment.js
Last active April 2, 2024 20:18
Here’s an example of my current web app user agent, device, and/or feature detection approach. I tend to inline this in the page header just before the stylesheet as part of the distribution build. A benefit of this approach is that detection is done early without any external dependencies. It’s also straightforward to modify or extend while you…
env = (function() {
var flags = {}, ua = navigator.userAgent, el = document.createElement('div'), video = document.createElement('video'), audio = document.createElement('audio'), root = document.documentElement, i
function flag(names) {
names = names.split(' ')
for (i = 0; i < names.length; i++)
flags[names[i]] = true
}
function classnames() {
var names = [], name
for(name in flags) if (flags.hasOwnProperty(name))
@wpscholar
wpscholar / functions.php
Last active March 1, 2021 13:26
Enqueueing IE conditional stylesheets in WordPress the right way
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
/**
* Example callback function that demonstrates how to properly enqueue conditional stylesheets in WordPress for IE.
* IE10 and up does not support conditional comments in standards mode.
*
* @uses wp_style_add_data() WordPress function to add the conditional data.
* @link https://developer.wordpress.org/reference/functions/wp_style_add_data/
@fabianmaass
fabianmaass / gist:5533458
Last active December 17, 2015 02:08
Applescript to remotely rate iTunes Songs in a Shared Library credits go to dougs iTunes Scripts esp. dougscripts.com/itunes/itinfo/diy1network17.php
global remUserName, remHostIPAddr, remAddr
my get_login_info()
tell application "iTunes"
set numList to {"0", "1", "2", "3", "4", "5"}
set selectedRating to {choose from list numList}
set selectedRating to (selectedRating * 20)
set sel to selection
@JvanderHeide
JvanderHeide / W3 Total Cache Flushing
Created January 20, 2014 14:23
Place this file somewhere and call it directly or via a cron tab. It allows you to flush all, or an array of pages. I'm using this to clear the cache of a pages that contain a date reference, at midnight. This is particularly useful when using "Disk Enhanced" page caching with the W3TC plugin, since WP_cron does not work with it. You might want …
<?php
// Flush everything or just some pages
$flush_all_pages = false;
// An array of urls to flush (required if $flush_all_pages is false)
$urls = array(
'http://www.example.com/',
);
//Set W3TC Constants
@spivurno
spivurno / gw-gravity-forms-emoji-handler.php
Created August 6, 2014 21:59
Gravity Wiz // Gravity Forms // Remove or Validate Emojis ✮
<?php
/**
* Gravity Wiz // Gravity Forms // Remove or Validate Emojis ✮
*
* Automatically remove or provide a validation error when emojis are submitted via a Gravity Form field.
*
* @version 1.0
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
* @link http://gravitywiz.com/...
@chrisvanpatten
chrisvanpatten / readme.md
Last active September 18, 2020 14:16
Super-simple way to grab a few Instagram images and cache them w/ WordPress

This is an easy way to integrate a basic Instagram feed into a WordPress site.

Setup

First, register with Instagram's developer program, then register a client. Set the client ID they provide you in line 4.

Second, get your Instagram user ID by running this in your terminal:

curl -X GET https://api.instagram.com/v1/users/search\?q\=USERNAME\&client_id\=CLIENT_ID
define('WP_DEBUG', true);
if ( WP_DEBUG ) {
/**
* Turn on error logging and show errors on-screen if in debugging mode
*/
@error_reporting( E_ALL );
@ini_set( 'log_errors', true );
@ini_set( 'log_errors_max_len', '0' );
@lucasstark
lucasstark / gist:8af76add84b5cfd60977
Created February 3, 2016 12:04
Reset all timezones in wordpress multisite.
<?php
add_action('init', 'maybe_reset_timezone');
function maybe_reset_timezone(){
if (isset($_GET['temp-reset-timezone'])) {
$sites = wp_get_sites();
foreach($sites as $site){
@timothyjensen
timothyjensen / functions.php
Last active April 24, 2024 18:20
Enforce anti-spam honeypot on all Gravity Forms forms
<?php
/**
* Enforce anti-spam honeypot on all Gravity forms.
*
* @param array $form
*
* @return array $form
*/
add_filter( 'gform_form_post_get_meta', function ( $form ) {