Skip to content

Instantly share code, notes, and snippets.

View donaldallen's full-sized avatar

Donald Allen donaldallen

View GitHub Profile
/*
* This "translates" PHP module package names into system-specific names.
*/
define puphpet::php::module (
$service_autorestart
){
$package = $::osfamily ? {
'Debian' => {
var communities = new Bloodhound({
datumTokenizer: function(datum) {
return Bloodhound.tokenizers.whitespace(datum.title);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: {
cache: false,
url: '/wp-json/wp/v2/communities',
filter: function(response) {
return $.map(response, function(community) {
server {
listen [::]:80;
listen 80;
# listen on both hosts
server_name donaldallen.com www.donaldallen.com;
# and redirect to the https host (declared below)
# avoiding http://www -> https://www -> https:// chain.
return 301 https://www.donaldallen.com$request_uri;
<?php
add_filter('rewrite_rules_array', function ($rules) {
$new_rules = [];
$new_rules['^locations/(.+?)/(.+?)/(.+?)/?$'] = 'index.php?area=$matches[1]&area=$matches[2]&area=$matches[3]';
$new_rules['^locations/(.+?)/(.+?)/(.+?)/?$'] = 'index.php?area=$matches[1]&area=$matches[2]&locations=$matches[3]';
$new_rules['^locations/(.+?)/(.+?)/?$'] = 'index.php?area=$matches[1]&locations=$matches[2]';
$new_rules['^locations/(.+?)/(.+?)/?$'] = 'index.php?area=$matches[1]&area=$matches[2]';
$new_rules['^locations/(.+?)/?$'] = 'index.php?area=$matches[1]';
@donaldallen
donaldallen / gist:8446431
Created January 15, 2014 22:56
nginx config with hhvm
server {
listen 80;
root /var/www/mywebsite.ca/public;
index index.php index.html index.htm;
server_name www.mywebsite.ca mywebsite.ca;
location ~ \.php$ {
fastcgi_keep_conn on;
@donaldallen
donaldallen / gist:8056458
Created December 20, 2013 15:36
Add the current page slug to your body class. Very handy!
<?php
add_filter('body_class', function($classes) {
global $wpdb, $post;
if (is_page()) {
if ($post->post_parent) {
$parent = end(get_post_ancestors($current_page_id));
} else {
$parent = $post->ID;
}
$post_data = get_post($parent, ARRAY_A);
// From this
section.divisions:not(.hero) {
padding:3em 3em;
background-color:$greyLighter;
text-align:center;
a {
display:block;
color:$greyDark;
font-size:em(14);
<?php
// My rewrite
$our_thinking_structure = 'our-thinking/%category%/%postname%';
$wp_rewrite->add_permastruct('our_thinking', $our_thinking_structure, false);
// Going to /our-thinking/scenarios/a-spirit-of-entrepreneurship/ works just fine.
// But going to /our-thinking/scenarios/ tries to load an archive page.
// Can I get it to load the page I have set in WP instead?
$leader_structure = '/performance/leaders/%leader%';
$wp_rewrite->add_rewrite_tag("%leader%", '([^/]+)', "leader=");
$wp_rewrite->add_permastruct('leader', $leader_structure, false);
// Works
http://test.dev/?leader=from-basement-startup-to-global-force#more-118
// Doesn't work
http://test.dev/performance/leaders/from-basement-startup-to-global-force
@donaldallen
donaldallen / gist:7666810
Created November 26, 2013 21:44
Using HTML5's article for blog previews.
<article role="article" itemscope itemtype="http://schema.org/BlogPosting">
<img src="someimage.jpg">
<header>
<h5><a href="#">TedX Edmonton Story (21pt)</a></h5>
<p><time itemprop="dateCreated" datetime="2013-10-12">Wednesday, October 12, 2013</time></p>
</header>
<p>15/24pt Velit auctor aliquet. Aenean sollicitudin, lorem quis bibendum auctor, nisi elit consequat ipsum, nec sagittis sem nibh id elit. Duis sed odio sit amet nibh vulputate cursus a sit amet mauris. Morbi accumsan ipsum velit. Nam nec tellus a odio tincidunt auctor a ornare odio himenaeos.</p>