Skip to content

Instantly share code, notes, and snippets.

View tormjens's full-sized avatar

Tor Morten Jensen tormjens

View GitHub Profile
@tormjens
tormjens / index.php
Created April 5, 2016 10:51
Convert a HTML table to array to a design element (for when client deliver some content in a word/excell table)
<!DOCTYPE html>
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
ini_set('default_charset', 'utf-8');
@tormjens
tormjens / provision-custom.sh
Created November 20, 2015 11:09
Lighter VVV Provision. Remove all updates. We just want to set up a new site got damn it!
#!/bin/bash
# Run wp-cli as vagrant user
if (( $EUID == 0 )); then
wp() { sudo -EH -u vagrant -- wp "$@"; }
fi
# RESTART SERVICES
#
# Make sure the services we expect to be running are running.
@tormjens
tormjens / query
Created June 29, 2015 11:12
Query Filter
add_action('pre_get_posts', function($query) {
if(is_admin()) {
return;
}
if(!$query->is_main_query()) {
return;
}
@tormjens
tormjens / anunarock.sh
Last active August 29, 2015 14:23
Anunatak Bedrock Init
#!/bin/sh
echo "%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#%#"
INSTALL="none"
VAGRANT="$HOME/vagrant-local"
while getopts :n:u:v FLAG; do
case $FLAG in
n) #set option "a"
@tormjens
tormjens / styke
Created June 9, 2015 08:29
Google Map Styles
[
{
"featureType":"administrative",
"elementType":"labels.text.fill",
"stylers":[
{
"color":"#444444"
}
]
},
@tormjens
tormjens / create.sh
Created April 28, 2015 11:53
Simple shell script to copy a Roots bedrock template
#!/bin/sh
# default path
dir="$PWD"
parentdir="$(dirname "$dir")"
template="$dir/template"
subdomains="$parentdir/subdomains"
domain="dev.anunatak.com"
# ask for template path
@tormjens
tormjens / download.php
Created April 24, 2015 12:41
Download and replace images in a text
function id_replace_images($content) {
$dom = new domDocument;
$dom->loadHTML('<?xml encoding="UTF-8">' . $content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
// dirty fix
foreach ($dom->childNodes as $elem)
if ($elem->nodeType == XML_PI_NODE)
$dom->removeChild($elem); // remove hack
@tormjens
tormjens / breakpoint.scss
Created April 23, 2015 12:54
Foundation Breakpoint Mixin
@mixin breakpoint($breakpoint, $orientation:"") {
$break: $breakpoint;
$orient: "";
@if $breakpoint == 'small' {
$break: $small-only;
@tormjens
tormjens / my_filter_user_query
Created December 11, 2014 13:24
BuddyPress: Show users that do not have groups based on a get parameter
/**
* Filters the query
*
* @param string $query The query instance
* @param array $sql The array of the query to be run
*
* @return array
**/
function bp_filter_member_query( $query, $sql ) {
@tormjens
tormjens / new_get_template_part.php
Created December 11, 2014 09:58
Improved get_template_part
/**
* An improved version for loading template parts.
*
* Load a template part into a template
*
* Makes it easy for a theme to reuse sections of code in a easy to overload way
* for child themes.
*
* Includes the named template part for a theme or if a name is specified then a
* specialised part will be included. If the theme contains no {slug}.php file