Skip to content

Instantly share code, notes, and snippets.

@lgladdy
lgladdy / banes-ishare.php
Last active May 27, 2018 20:46
BANES Council Data from iShare
$pc = 'ba11be';
//HACKY HACKY. GET the first properly in the postcode.
$url = 'http://isharemaps.bathnes.gov.uk/getdata.aspx?service=LocationSearch&RequestType=LocationSearch&location='.$pc.'&pagesize=1&startnum=1';
$data = json_decode(file_get_contents($url),true);
$x = $data['data'][0][4];
$y = $data['data'][0][5];
$id = $data['data'][0][0];
@lgladdy
lgladdy / assets.php
Last active August 23, 2018 13:52
Add zurb foundation widescreen/responsive-embed code to gutenberg video blocks.
function foundation_gutenberg_wrappers()
{
if (defined('WP_DEBUG') && WP_DEBUG) {
$gutenberg_file = '/js/raw/gutenberg.js?no_cache=' . time();
} else {
$gutenberg_file = '/js/raw/gutenberg.js';
}
wp_enqueue_script('foundation-gutenberg-extensions', get_template_directory_uri() . $gutenberg_file, array('wp-blocks'));
}
add_action('enqueue_block_editor_assets', 'foundation_gutenberg_wrappers');
@lgladdy
lgladdy / gruntfile
Created May 13, 2014 08:07
This is the gruntfile that powers gladdy.co.uk. It's for the blog post here: http://www.gladdy.co.uk/blog/2014/04/13/using-uncss-and-grunt-uncss-with-wordpress/
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
sourceMap: true,
sourceMapIncludeSources: true,
sourceMapIn: 'js/app.coffee.js.map'
},
@lgladdy
lgladdy / acf-use-editor-palette.js
Created July 22, 2021 07:02
Set the color picker palette to match the block editor's
acf.addFilter('color_picker_args', function (args) {
const settings = wp.data.select( "core/editor" ).getEditorSettings();
let colors = settings.colors.map(x => x.color);
args.palettes = colors;
return args;
});
@lgladdy
lgladdy / twitter-application-only-auth.php
Created March 12, 2013 09:46
A working example of Twitter's new application-only auth, written in PHP.
<?php
//This is all you need to configure.
$app_key = '';
$app_token = '';
//These are our constants.
$api_base = 'https://api.twitter.com/';
$bearer_token_creds = base64_encode($app_key.':'.$app_token);
@lgladdy
lgladdy / grunt-sitemap.php
Created April 13, 2014 14:25
Grunt Sitemap Generator plugin for Wordpress
<?php
/**
* Plugin Name: Grunt Sitemap Generator
* Plugin URI: http://www.github.com/lgladdy
* Description: Generate a JSON list of every page on a site so it can be used with grunt and uncss. Create a folder in /wp-content called mu-plugins, and drop this code into that folder, as grunt-sitemap.php
* Author: Liam Gladdy
* Author URI: http://gladdy.co.uk
* Version: 1.0
*/
//block.json
{
"name": "simple-test-block",
"title": "Simple Test Block",
"description": "Simple Test Block",
"category": "theme",
"icon": "admin-comments",
"acf": {
"mode": "preview",
"renderTemplate": "render.php"
@lgladdy
lgladdy / _wordpress_core.scss
Created April 13, 2014 19:02
WordPress Core Styles in SASS
/* =WordPress Core - Sassified.
-------------------------------------------------------------- */
.alignnone {
margin: 5px 20px 20px 0;
}
.aligncenter, div.aligncenter {
display: block;
margin: 5px auto 5px auto;
}
@lgladdy
lgladdy / acf_blocks_parse_node_attr.js
Last active September 8, 2023 11:52
acf_blocks_parse_node_attr demo
acf.addFilter('acf_blocks_parse_node_attr', function( currentValue, nodeAttr ){
if (nodeAttr.name.startsWith('v-')) {
return { name: nodeAttr.name, value: nodeAttr.value };
}
return currentValue;
});
@lgladdy
lgladdy / block.json
Last active November 24, 2023 12:36
An example ACF block.json which disables align controls, but forces a default to wide
{
"name": "automatic-wide-width",
"title": "Automatically Align Wide",
"description": "A demo block.json for a forced align-wide block",
"apiVersion": 2,
"acf": {
"mode": "edit",
"renderTemplate": "render.php"
},
"supports": {