Skip to content

Instantly share code, notes, and snippets.

@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
_____________
/ ____ \
_____/ \ \ \
/\ \ \___\ \
/ \ \ \
/ / / _______\
/ / / \ /
/ / / \ /
#!/bin/bash
#
# provision-post.sh
#
# Does stuff
#
xdebug_on
[30-Jul-2014 08:22:42 UTC] PHP Strict standards: Redefining already defined constructor for class GADAdminDashboard in /srv/www/test/htdocs/wp-content/plugins/google-analytics-dashboard/gad-admin-dashboard.php on line 29
[30-Jul-2014 08:22:42 UTC] PHP Stack trace:
[30-Jul-2014 08:22:42 UTC] PHP 1. {main}() /srv/www/test/htdocs/wp-admin/customize.php:0
[30-Jul-2014 08:22:42 UTC] PHP 2. require_once() /srv/www/test/htdocs/wp-admin/customize.php:12
[30-Jul-2014 08:22:42 UTC] PHP 3. require_once() /srv/www/test/htdocs/wp-admin/admin.php:30
[30-Jul-2014 08:22:42 UTC] PHP 4. require_once() /srv/www/test/htdocs/wp-load.php:29
[30-Jul-2014 08:22:42 UTC] PHP 5. require_once() /srv/www/test/htdocs/wp-config.php:60
[30-Jul-2014 08:22:42 UTC] PHP 6. include_once() /srv/www/test/htdocs/wp-settings.php:210
[30-Jul-2014 08:22:42 UTC] PHP Strict standards: Redefining already defined constructor for class GADAdminDashboardUI in /srv/www/test/htdocs/wp-content/plugins/google-analytics-dashboard/gad-admin-dashboar
@philipjohn
philipjohn / pj_error_log.function.php
Last active August 29, 2015 14:04
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() );
function pj_error_log(){
// Get line numbers and such
$bt = debug_backtrace();
$caller = array_shift($bt);
// First we check if we're being asked to print a pretty message
if ( func_num_args() == 2 && is_string( func_get_arg(0) ) ) {
@philipjohn
philipjohn / import.sh
Last active August 29, 2015 14:10
Grabs a list of blogs and runs some tasks on each to set up a new multisite
if [ ! -f menus.wxr ]; then
echo "You need to export the menus for the menu setting to work, export to a menus.wxr file"
echo "remember to export the 'nav_menu_item' post type to a menus.wxr file before running"
exit;
fi
# Get a list of blogs to loop through
blogs=$(wp site list --fields="site_id,blog_id,url" --format="csv" --path="../../repository/htdocs/wp")
for entry in $blogs
@philipjohn
philipjohn / suffusion-translate-https.diff
Created February 4, 2015 11:14
Fixes mixed content issues with Google Translate in Suffusion theme
Index: functions/actions.php
===================================================================
--- functions/actions.php (revision 43062)
+++ functions/actions.php (working copy)
@@ -1004,8 +1004,9 @@
}
if (!is_admin() && is_active_widget('Suffusion_Google_Translator', false, 'suf-google-translator', true)) {
+ $protocol = is_ssl() ? 'https' : 'http';
// For some reason the translation widget fails if we load the JS in the header. Hence we are overriding the header/footer JS setting
@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
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() ) {