Skip to content

Instantly share code, notes, and snippets.

@philipjohn
philipjohn / the-uk-should-leave-the-eu
Created May 10, 2014 21:02
An example of using markdown to question/answer generation in a "Who Should I Vote For?" system
---
question: The UK should leave the EU
category: European Union
---
# Answers
## Strongly Agree
UKIP
@philipjohn
philipjohn / facetious-bug-test.php
Created May 19, 2014 12:13
For testing duplication suspect bug in Facetious
<?php
/*
* Plugin Name: Facetious Bug Test
* Description: Just testing
* Author: Code For The People
*/
function fbt_taxos() {
register_extended_taxonomy( 'doc-type', 'attachment' );
@philipjohn
philipjohn / post.md
Created May 25, 2014 18:34
Blog post about candidates collab thing wotsit

Collaborating on European Election data in GitHub

On Friday my friend and cracking coder Stuart Harrison, of the Open Data Institute, launched a collaborative project to collate European Parliament 2014 election results for the UK regions using GitHub. As I type I'm waiting for the start of results night so I can help with that project.

Inspired, I spent some of today building something similar to build a list of candidates for the UK General Election in 2015. Through a recent work project I've realised there isn't really a good data source for candidates, and the method Stuart devised for the European election results seemed like a great fit.

Contribute!

You can help build this with me, and all you really need to know is how to create and edit CSV files. I've split the following instructions into developer and non-developer guides to give each a more easy-to-follow set.

@philipjohn
philipjohn / ascii-for-the-people
Last active August 29, 2015 14:02
ASCII For The People
/* Copyright 2014 Code for the People Ltd
_____________
/ ____ \
_____/ \ \ \
/\ \ \___\ \
/ \ \ \
/ / / _______\
/ / / \ /
/ / / \ /
@philipjohn
philipjohn / pj_error_log.function.php
Last active May 12, 2025 12:45
A useful error logging function intended for use with WordPress. Simply add to your wp-config.php, or other non-version controlled PHP file.
<?php
if ( ! defined( 'PJID' ) ) define( 'PJID', uniqid() );
if ( ! defined( 'PJLOG' ) ) define( 'PJLOG', ABSPATH . 'pj.log' );
function pj_error_log(){
// Get line numbers and such
$caller = array_shift( debug_backtrace() );
$prefix = implode( '::', [
PJID,
$caller['file'],
add_filter( 'pre_update_option', 'll_kill_frontend_rewrite_rules_update', 10, 3 );
function ll_kill_frontend_rewrite_rules_update( $value, $option, $old_value ) {
// We're only concerned with the rewrite rules option.
if ( 'rewrite_rules' !== $option ) {
return $value;
}
// We want to concentrate on frontend requests only.
if ( ! is_admin() && ! is_user_logged_in() ) {
@philipjohn
philipjohn / time-to-publish.php
Created September 25, 2018 13:05
A WordPress plugin for tracking the time to publish for posts.
<?php
/*
Plugin Name: Time to Publish
Plugin URI: https://vip.wordpress.com
Description: Track "Time to Publish" on your WordPress site.
Version: 0.1.0
Author: WordPress.com VIP
Author URI: http://vip.wordpress.com
Text Domain: time_to_publish
Domain Path: /languages
@philipjohn
philipjohn / rename-comments.php
Created October 1, 2019 12:04
Rename Comments PoC
<?php
/**
* Plugin Name: Rename Comments
* Description: Provides themes with the ability to allow users to rename comments.
* Version: 0.1.0
* Author: Philip John, Automattic
* Author URI: https://automattic.com
* Text Domain: rename-comments
* Domain Path: /languages
<?php
/*
Migrate from WP User Avatar to Simple Local Avatars
Allows sites to easily move away from the WP User Avatar plugin and switch to Simple Local Avatars instead.
Run by invoking with WP CLI like so:
`wp eval-file migrate-wp-user-avatar.php`
Author: Philip John
@philipjohn
philipjohn / scroll-snap.html
Created October 12, 2022 08:58
Testing scroll snap
<html>
<head>
<title>Scroll Snap</title>
<style type="text/css">
* {
box-sizing: border-box;
}
.scroll-container {
max-height: 100vh;
overflow-y: scroll;