Skip to content

Instantly share code, notes, and snippets.

View ambercouch's full-sized avatar

Richard Arnold ambercouch

View GitHub Profile
@ambercouch
ambercouch / functions.php
Created August 14, 2018 11:22
Remove all the style sheets from a wordpress theme except $styles_to_keep
// add the action
add_action('wp_print_styles', 'ac_remove_default_styles');
function ac_remove_default_styles ()
{
// get all styles data
global $wp_styles;
$styles_to_keep = array('admin-menu');
@ambercouch
ambercouch / functions.php
Last active August 14, 2018 11:20
Output all the enqeued stylesheet use in the current wordpress theme to the javascript console.
function ac_inspect_scripts() {
global $wp_styles;
echo '<script id="ac_inspect_scripts">';
foreach( $wp_styles->queue as $handle ) :
echo 'console.log("' . $handle . '");';
endforeach;
echo '</script>';
}
add_action( 'wp_print_scripts', 'ac_inspect_scripts' );
@ambercouch
ambercouch / fix-missing-command-prompt.txt
Created April 4, 2018 14:33
Fix Vagrant ssh missing command prompt
#Run this in terminal before starting vagrant ssh
export VAGRANT_PREFER_SYSTEM_BIN=1
@ambercouch
ambercouch / Vagrantfile
Created April 2, 2018 08:15
Fix Scotch Box Authentication Failure
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box"
config.vm.network "private_network", ip: "192.168.33.25"
config.vm.hostname = "scotchbox"
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
config.vm.provision :shell, path: "phpmyadmin.sh"
@ambercouch
ambercouch / ac_bc.js
Created March 21, 2018 14:51
Added breadcrumbs from the url path with javascript
function titleCase(str) {
str = str.toLowerCase().split(' ');
for (var i = 0; i < str.length; i++) {
str[i] = str[i].charAt(0).toUpperCase() + str[i].slice(1);
}
return str.join(' ');
}
var bcElements = document.querySelectorAll('[data-breadcrumbs]');
var currentPath = window.location.pathname;
@ambercouch
ambercouch / acDefer.js
Last active January 27, 2018 10:35
A javascript function that performs a test until it passes or for a set number of time. Useful for wait for jQuery to load.
function acDefer(successMethod, failMethod, testMethod, pause, attempts) {
var defTest = function () {
return window.jquery;
};
var defFail = function () {
console.log('jQuery not load');
}
var defSuccess = function () {
console.log('jQuery load');
}
@ambercouch
ambercouch / ac_script.js
Last active January 25, 2018 09:36
Javascript template. Execute based on page template etc.
/**
* Created by Richard on 19/09/2016.
*/
//console.log('ACTIMBER');
ACSCRIPT = {
common: {
init: function () {
'use strict';
//uncomment to debug
@ambercouch
ambercouch / retina-mq.css
Last active January 16, 2018 07:10
CSS Media queries that detect screen resolution
@media
(-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
/* Retina-specific stuff here */
}
/* 1.25 dpr */
@media
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi){
@ambercouch
ambercouch / general.php
Last active January 9, 2018 14:50
Craft locales with their own domains, Plus dev domains
<?php
/**
* General Configuration
*
* All of your system's general configuration settings go in here.
* You can see a list of the default settings in craft/app/etc/config/defaults/general.php
*/
@ambercouch
ambercouch / site-lang-selector.html
Created January 9, 2018 12:13
Craft Locale Switcher
<nav class="locale-switch">
<ul class="locale-switch__list">
{% set locales = craft.i18n.getSiteLocales() %}
{% for locale in locales %}
{% set entryURL = craft.config.siteUrl[locale.id] %}
{% if entry is defined %}
{% set entryLocal = craft.entries.id(entry.id).locale(locale.id).first %}