View EncryptCookies.php
<?php namespace App\Http\Middleware;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Cookie\Middleware\EncryptCookies as BaseMiddleware;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
// The first two functions are identical to the originals in the parent class
// other than the sections marked "MOD". The third function is a new helper
View cf7-campaignmonitor.php
<?php
/*
Plugin Name: Contact Form 7 - Campaign Monitor Addon
Plugin URI: http://www.bettigole.us/published-work/wordpress-contributions/campaign-monitor-addon-for-contact-form-7/
Description: Add the power of CampaignMonitor to Contact Form 7
Author: Joshua Bettigole
Author URI: http://www.bettigole.us
Version: 1.06 (Modified)
https://wordpress.org/support/topic/contact-form-7-campaign-monitor-addon-broken
View amfe.php
<?php
/*
Plugin Name: Add more files extensions
Plugin URI: http://irz.fr/add-more-files-extensions/
Description: Add more files extensions with a new field in your <a href="options-media.php">Media Settings</a>.
Version: 0.2
Author: Arthur Lacoste
Author URI: http://irz.fr
*/
View download-cpanel-database.sh
#!/bin/bash
# This is a script I used to download my live site database onto my development
# server when I used a web host that used cPanel, but didn't give me access to
# mysqldump over SSH (because they had Jailshell enabled).
# Note: The database name (DBNAME) excludes the account name prefix - i.e.
# "dbname" not "sitename_dbname".
curl http://USERNAME:PASSWORD@HOSTNAME:2082/getsqlbackup/DBNAME.sql.gz \
View sudo-relaunch.py
# This is how I ensure a Python script is launched as root, and automatically
# call 'sudo' to re-launch it as root if not.
# I found it useful to check the parameters are valid *before* re-launching as
# root, so I don’t have to enter the sudo password if there is a problem with
# the parameters, or I just want the help message.
import os
import sys
View README.md

How to add a simple "star" flag to posts (a la Gmail).

This works by adding the "Starred" category to the post when the Star button is clicked, and removing it when Unstar is clicked. It was written for a private, single-user site - it doesn't support multiple users having different sets of starred posts.

It uses ajax, so it is fast and doesn't require a page reload.

Tested against WordPress 3.0.3.

Also see:

View detect-input-type.sh
# How to detect whether input is from keyboard, a file, or another process.
# Useful for writing a script that can read from standard input, or prompt the
# user for input if there is none.
# Source: http://www.linuxquestions.org/questions/linux-software-2/bash-scripting-pipe-input-to-script-vs.-1-570945/
if readlink /proc/$$/fd/0 | grep -q "^pipe:"; then
# Pipe input (echo abc | myscript)
elif file $( readlink /proc/$$/fd/0 ) | grep -q "character special"; then
# Terminal input (keyboard)
View filosofo-comments-preview-count-fix.php
<?php
// Filosofo Comments Preview [1] is a WordPress plugin that lets you preview
// comments on your blog before you submit them.
// In the current version (1.5) it doesn't increment the number of posts, so it
// still says "there are no comments" when you click Preview, even though the
// previewed comment is directly under it.
// This little addition to the plugin will correct that - or you can put this in
View starred-posts-widget.php
<?php
// This is a modification to the theme's functions.php that adds a widget to
// list all of the posts in the "Starred" category.
// Also see: Toggle "Starred" Category - https://gist.github.com/1966607
// It has no user-configurable options, because I just wanted it to do this one
// thing. (There may be plugins that do this and more, but I didn't take the
// time to search.)
View redirect-after-publish-v1.php
<?php
// Redirect to the post/page itself after publishing or updating a post in
// WordPress. This code is from the WordPress forum [1], modified so it doesn't
// redirect when saving a draft.
// [1]: http://wordpress.org/support/topic/redirect-to-new-post-after-publish
add_filter('redirect_post_location', function($location)