Skip to content

Instantly share code, notes, and snippets.

View alexwoollam's full-sized avatar
:octocat:

Alexander King Woollam alexwoollam

:octocat:
View GitHub Profile
### Keybase proof
I hereby claim:
* I am alexwoollam on github.
* I am awool (https://keybase.io/awool) on keybase.
* I have a public key ASCB9laMpb0JT3Yt-SiieYKmTv7PMqX1IdPjNVN_oXPALQo
To claim this, I am signing this object:
<?php
// ===================================================
// Load database info and local development parameters
// ===================================================
if ( file_exists( dirname( __FILE__ ) . '/local-config.php' ) ) {
define( 'WP_LOCAL_DEV', true );
include( dirname( __FILE__ ) . '/local-config.php' );
} else {
define( 'WP_LOCAL_DEV', false );
define( 'DB_NAME', '%%DB_NAME%%' );
@alexwoollam
alexwoollam / function.php
Last active March 10, 2022 00:29 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
/**
* Disables comments, Add below to existing function.php file.
*/
/** Disable support for comments and trackbacks in post types. */
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ( $post_types as $post_type ) {
if ( post_type_supports( $post_type, 'comments' ) ) {
@alexwoollam
alexwoollam / functions.php
Last active June 14, 2018 10:42
possible ai1ec bst/gmt fix
<?php
$query = "SELECT * FROM {$wpdb->posts} JOIN {$wpdb->prefix}ai1ec_events on ({$wpdb->prefix}ai1ec_events.post_id={$wpdb->posts}.ID)
WHERE post_type='ai1ec_event' AND post_status='publish' AND {$wpdb->prefix}ai1ec_events.start > '".time()."' ORDER BY {$wpdb->prefix}ai1ec_events.start limit 3";
$results = $wpdb->get_results( $query ); // get result form the query
ob_start();
foreach($results as $result){
$title = ($result->post_title); // Returns the post type title
@alexwoollam
alexwoollam / matchsidebar.js
Last active September 30, 2018 17:32
wordpress match sidebar and body height
//This will match the pages content height if the sidebar is bigger.
getSidebarHeight();
function getSidebarHeight(){
var sidebar = document.getElementById('sidebar_inner');//<- Sidebar ID
var sidebarHeight = sidebar.offsetHeight;
var body = document.getElementById('postBody'); //<- Body ID
var contentHeight = body.offsetHeight;
var sidebarHeightPixels = sidebarHeight + "px";
if(contentHeight < sidebarHeight){
@alexwoollam
alexwoollam / Jenkinsfile
Last active September 5, 2018 15:04
Jenkinsfile for wordpress wip
#!/bin/sh
pipeline {
agent any
stages {
stage('Checkout Repo') {
steps {
checkout scm
}
}
stage('Build') {
@alexwoollam
alexwoollam / functions.php
Last active September 30, 2018 17:32
Fixes Time.ly ai1ec GMT/BST issues, (events being a day behine in summer)
/**
* Get start and end of BST.
*/
$bst-month = date( 'Y/03/d', strtotime('last sunday of march' ) );
$gmt-month = date( 'Y/10/d', strtotime('last sunday of october' ) );
$event_date_sanitized = $datetime->format( 'Y/m/d' );
if ( $result->allday ){
if ( $event_date_sanitized >= $bst-month && $event_date_sanitized <= $gmt-month ){
$datetime->modify( '+1 day' );
@alexwoollam
alexwoollam / _mixins.scss
Last active January 30, 2019 11:22
Neat media query in sass
// Breakpoints (this map lives in variables).
$breakpoint:(
'xxsmall': 400px, // max-width
'xsmall': 400px, // min-width...
'small': 600px,
'medium': 1000px,
'large': 1200px,
'xlarge': 1400px,
'xxlarge': 1600px,
@alexwoollam
alexwoollam / functions.php
Created March 6, 2019 21:54
It's possible to use namespaces by hooking onto the timber/loader/loader filter.
add_filter( 'timber/loader/loader', function( $loader ){
$loader->addPath( __DIR__ . "/views/components", "components" );
return $loader;
} );
// To use the namespace in your Twig template, just include it with an @ prefix.
{{ include( '@components/filename.twig' ) }}
@alexwoollam
alexwoollam / style.scss
Last active September 19, 2019 14:24
Bootstrap responsive helper/
body{
// Dev tool, remove once done! //
@include media('xs') {
&::before{
content: "xs";
position: fixed;
top: 0px;
height: 20px;
width: 100%;
background-color: #D9B504;