Skip to content

Instantly share code, notes, and snippets.

View BinaryMoon's full-sized avatar
🏠
Working from home

Ben Gillbanks BinaryMoon

🏠
Working from home
View GitHub Profile
@BinaryMoon
BinaryMoon / PHPDiff.php
Created May 13, 2017 22:35
do a diff between files
function PHPDiff ($old, $new) {
$t1 = $old;
$t2 = $new;
# build a reverse-index array using the line as key and line number as value
# don't store blank lines, so they won't be targets of the shortest distance
# search
@BinaryMoon
BinaryMoon / jetpack-logo.php
Created May 20, 2017 10:36
Replace jetpack logo with custom logo
<?php
/**
* Check for Jetpack logo and replace with core logo functionality.
*
* @package granule
*/
/**
* Remove Jetpack site-logo functionality and replace with support for custom logo.
*
@BinaryMoon
BinaryMoon / widgets.js
Last active May 27, 2019 21:40
Some javascript to fix media widget display issues in WordPress 4.8
// Use a timeout so we can ensure any resizing/ transitions are complete. May need to make the duration a little longer.
// This code should be called from the code that makes the hidden widgets visible. For example in the button click event.
// Requires jQuery for a couple of bits - shouldn't be a problem since most WordPress themes use it.
setTimeout(
function() {
// Remove any media elements currently initialised.
// Should change .sidebar-overlay to match the html on your site.
// This should be some sort of container that holds the hidden widgets.
// The container is used to ensure widgets in visible sidebars are not affected.
@BinaryMoon
BinaryMoon / widget.php
Created November 15, 2017 10:42
An example function showing how to convert a WordPress category id to a slug.
<?php
function prefix_convert_category_id_to_slug( $value ) {
if ( is_int( $value ) ) {
$category = get_term( $value, 'category' );
if ( is_wp_error( $category ) ) {
return $value;
}
$value = $category->slug;
@BinaryMoon
BinaryMoon / csscolor.php
Created March 26, 2018 07:32
Create colour palette with contrasting colours based upon single colour
<?php
/**
* Class for creating readable colour schemes
*
* @package Opti
*/
/*
csscolor.php
Copyright 2004 Patrick Fitzgerald
@BinaryMoon
BinaryMoon / enable-privacy.php
Last active May 26, 2018 19:05
A simple WordPress plugin that changes the privacy policy link to point to a specific url. Perfect for theme demo sites. Just add it to your mu-plugins directory.
<?php
/**
* Plugin Name: Enable Privacy Link
* Plugin URI: https://prothemedesign.com
* Description: Enable a privacy policy link and point it to another url.
* Author: Ben Gillbanks
* Version: 1.0
* Author URI: https://prothemedesign.com
*
* @package ptd
@BinaryMoon
BinaryMoon / jetpack-featured-content.php
Created June 25, 2018 19:57
Filter Jetpack Featured Content
@BinaryMoon
BinaryMoon / broadsheet-slider-params.php
Created June 26, 2018 19:39
Filter the Broadsheet slider properties
<?php
/**
* Plugin Name: Change Broadsheet slide quantity
* Plugin URI: https://prothemedesign.com
* Description: Change number of posts that appear in the Broadsheet slider.
* Author: Ben Gillbanks
* Version: 1.0
* Author URI: https://prothemedesign.com
* Text Domain: broadsheet
*/
@BinaryMoon
BinaryMoon / mimbopro-header.php
Created July 8, 2018 11:57
Change Mimbo Pro so that the header can be a custom height
<?php
/**
* Plugin Name: Change Mimbo Pro Header Size
* Plugin URI: https://prothemedesign.com
* Description: Change the height of the header image on Mimbo Pro.
* Author: Ben Gillbanks
* Version: 1.0
* Author URI: https://prothemedesign.com
* Text Domain: mimbopro
*/
@BinaryMoon
BinaryMoon / label-extra-navigation.php
Created August 13, 2018 19:09
Label Extra Navigation
<?php
/**
* Plugin Name: Label additional navigation
* Plugin URI: https://prothemedesign.com
* Description: Add an additional navigation position under the header image.
* Author: Ben Gillbanks
* Version: 1.0
* Author URI: https://prothemedesign.com
*
* @package ptd