Skip to content

Instantly share code, notes, and snippets.

View tomjn's full-sized avatar
🎯
Focusing

Tom J Nowell tomjn

🎯
Focusing
View GitHub Profile
@lgladdy
lgladdy / hello-taylor.php
Last active August 29, 2016 18:15
A WordPress plugin to replace Hello Dolly lyrics with the infinitely better Taylor Swift.
<?php
/*
Plugin Name: Hello Taylor
Plugin URI: https://gist.github.com/lgladdy/9e1a7303c6a6bf43b9b1
Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in <strike>two</strike> words sung most famously by <strike>Louis Armstrong: Hello, Dolly.</strike>Taylor Swift. When activated you will randomly see a lyric from <strike><cite>Hello, Dolly</cite></strike><cite>Taylor Swift</cite> in the upper right of your admin screen on every page.
Author: Liam Gladdy (based on Hello Dolly by Matt Mullenweg)
Version: 1.1
Author URI: http://www.twitter.com/lgladdy & http://ma.tt/
*/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thefuxia
thefuxia / snippets.txt
Created February 1, 2014 18:41
Moderation snippets for WordPress Stack Exchange
## Comments added to deleted comments and answers, visible for the post author only.
Sorry, but this is not [an answer](http://wordpress.stackexchange.com/questions/how-to-answer).
[An answer should be more than just a link to an external site](http://wordpress.stackexchange.com/help/deleted-answers). Please add a solution.
[Ask a new question.](http://wordpress.stackexchange.com/questions/ask) Please don’t misuse the answer field for questions. Thanks.
[You must disclose your affiliation in your answers.](http://wordpress.stackexchange.com/help/behavior)
@westonruter
westonruter / force_balance_tags2.php
Last active August 21, 2019 08:44
Use DOMDocument to do a more robust job at force_balance_tags.
<?php
/**
* Use DOMDocument to do a more robust job at force_balance_tags.
*
* "force_balance_tags() is not a really safe function. It doesn’t use an HTML parser
* but a bunch of potentially expensive regular expressions. You should use it only if
* you control the length of the excerpt too. Otherwise you could run into memory issues
* or some obscure bugs." <http://wordpress.stackexchange.com/a/89169/8521>
*
@Rarst
Rarst / doge.php
Last active December 27, 2019 10:34
Doge snippet for WordPress
<?php
add_filter('gettext',fn($t)=>
@$t[4]&&@$GLOBALS['wp_locale']
?["Such $t","Very $t",'Wow'][rand(0,2)]
:$t);
@franz-josef-kaiser
franz-josef-kaiser / example_post_status.php
Created June 14, 2012 13:07
Add a custom post status for WP (custom) post types
<?php
// No, Thanks. Direct file access forbidden.
! defined( 'ABSPATH' ) AND exit;
// INIT
add_action( 'after_setup_theme', array( 'unavailable_post_status', 'init' ) );
class unavailable_post_status extends wp_custom_post_status
{
/**

Force Gutenberg to Fullscreen Mode

This is an example snippet for forcing the Gutenberg editor into full screen mode in anticipation of the change coming to WordPress 5.4.

@markjaquith
markjaquith / gist:2653957
Created May 10, 2012 15:36
WordPress Fragment Caching convenience wrapper
<?php
/*
Usage:
$frag = new CWS_Fragment_Cache( 'unique-key', 3600 ); // Second param is TTL
if ( !$frag->output() ) { // NOTE, testing for a return of false
functions_that_do_stuff_live();
these_should_echo();
// IMPORTANT
$frag->store();
// YOU CANNOT FORGET THIS. If you do, the site will break.
@niepi
niepi / osx_php_homebrew.setup.md
Created February 28, 2012 13:23
OSX PHP Homebrew Setup

install php

with mysql pgsql intl support

$ brew install php --with-apache --with-mysql --with-pgsql --with-intl

set php timezone in php ini

date.timezone = Europe/Vienna
@Rarst
Rarst / CommentsFeed.php
Last active July 28, 2021 10:27
Build Gist comments feed for specific user, using GitHub API.
<?php
namespace Rarst\GitHub\Gist;
use GuzzleHttp\Client;
use GuzzleHttp\Command\Guzzle\Description;
use GuzzleHttp\Command\Guzzle\GuzzleClient;
/**
* Build Gist comments feed for specific user, using GitHub API.