Skip to content

Instantly share code, notes, and snippets.

@rob-gordon
rob-gordon / get_partial.php
Created July 18, 2017 21:42
scoped replacement for get_template_part
function get_partial($t) {
include( locate_template( 'template_parts/'.$t.'.php', false, false ) );
}
@rob-gordon
rob-gordon / wordpress roles and caps
Created July 18, 2017 15:22
all wordpress roles and capabilities
switch_themes
edit_themes
edit_theme_options
install_themes
activate_plugins
edit_plugins
install_plugins
edit_users
edit_files
manage_options
@rob-gordon
rob-gordon / to-webm.sh
Last active June 16, 2017 14:28
Useful Web Video ffmpeg commands
# converts an mp4 to webm
ffmpeg -i input-file.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output-file.webm
# grabs the first frame of the video for using as the <video> poster
ffmpeg -i input-file.mp4 -vframes 1 -f image2 video-poster.jpg
@rob-gordon
rob-gordon / template-hierarchy.yml
Last active June 8, 2017 00:47
A yaml file representing the wordpress template hierarchy
- index:
- paged:
- archive:
- author:
- author-$id:
- author-$nicename
- category:
- category-$id:
- category-$slug
- archive-$posttype
@rob-gordon
rob-gordon / template-hierarchy.js
Last active June 8, 2017 00:48
A javascript object representing the wordpress template hierarchy
var templateHierarchy = [
{
"index": [
{
"paged": [
{
"archive": [
{
"author": [
{
@rob-gordon
rob-gordon / query-acf.php
Created May 17, 2017 14:32
Confusing WP Query's with ACF
# Querying a relationship field (stored as a serialized array)
# https://www.advancedcustomfields.com/resources/querying-relationship-fields/
$related_posts = get_posts([
'post_type' => ['publication'],
'posts_per_page' => 6,
'meta_query' => [
[
'key' => 'related_research_area',
'value' => $cur_id,
@rob-gordon
rob-gordon / get-colors.sh
Last active May 15, 2017 22:18
use imageMagick and gsed to save count,hex of colors in an image
#!/bin/bash
# Return the histogram
fileToWrite="./colors.csv"
filename=""
regex='(\d+): '
if [ "$1" != "" ]; then # Test for positional argument
if [ -f "$1" ]; then # Test if regular file, not directory
filename="$1"
@rob-gordon
rob-gordon / 000-default.conf
Created April 4, 2017 21:46
local_wp_env.000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
@rob-gordon
rob-gordon / Vagrantfile
Last active April 4, 2017 21:51
local_wp_env.Vagrantfile
VAGRANTFILE_API_VERSION = "2"
## Configuration ##
site_title = myvar = ENV['SITENAME'] || "wordpress"
php_version = ENV['VERSION'] || "7.0"
generate_wp_config_local = ENV['GENERATE'] || true
## End Configuration ##
---
- hosts: all
become: true
tasks:
- name: set hostname
command: hostnamectl set-hostname {{sitetitle}}.local
- name: restart hostname