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 / 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 / jetpack-featured-content.php
Created June 25, 2018 19:57
Filter Jetpack Featured Content
@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 / 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 / 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 / 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 / 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 / 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 / widont.php
Last active April 6, 2017 08:06
Remove Widows from text in WordPress
/**
* Make last space in a sentence a non breaking space to prevent typographic widows.
*
* @param type $str
* @return string
*/
function theme_widont( $str = '' ) {
// Strip spaces.
$str = trim( $str );
@BinaryMoon
BinaryMoon / game.html
Created April 5, 2017 15:48
include variables
{% assign width=include.game.game_width | round %}
{% if width < 500 %}
{% assign width=500 %}
{% endif %}
<style>
.game-container {
max-width: {{ width }}px;
}
.game-container-inner {
padding-bottom: {{ include.game.game_height | times: 100 | divided_by: include.game.game_width }}%;