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 / build.sh
Last active December 10, 2016 08:39
WordPress Build Script
#! /usr/bin/env bash
# Reset timer
SECONDS=0
builddate=`date +"%B %e %Y"`
echo "Build begins: "$builddate
say Build process commenced $builddate
@BinaryMoon
BinaryMoon / gulp-util-get-theme.js
Last active November 16, 2016 11:44
Use gulp to check the textdomain in a WordPress theme
/**
* Get theme folder from theme parameter or use granule
*
* @returns {String|util.env.theme}
*/
function utilGetTheme() {
var theme = 'granule';
if ( util.env.theme ) {
# disable access to wp-config.php
<files wp-config.php>
order allow,deny
deny from all
</files>
# disable public error messages
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
@BinaryMoon
BinaryMoon / .csscomb.json
Last active November 26, 2016 16:32
Generate a WordPress rtl.css with Gulp
{
"exclude": ["node_modules/**"],
"verbose": true,
"remove-empty-rulesets": true,
"always-semicolon": true,
"color-case": "lower",
"block-indent": "\t",
"color-shorthand": true,
"element-case": "lower",
"eof-newline": true,
@BinaryMoon
BinaryMoon / 1.proposal.txt
Last active January 20, 2017 20:10
Improve WordPress Customizer Auto Update Partials Adoption
I think the reason there hasn't been much developer uptake in the auto refresh of the Customizer is that implementation is both:
1. complex (using javascript - something many theme developers are unaccustomed to outside of jquery)
and 2. has complex documentation. It's only because I've been following the many customizer changes in 4.7 that I have learnt how to implement the things I have.
Having now implemented auto updating partials for site title and description in a number of my themes I have seen that it's not as complicated as I first thought. I have also seen that the code is almost identical for each theme. The only thing that has changed is the css selector used to reference the title and description. You can see an example of the js implementation on _s - https://github.com/Automattic/_s/blob/master/js/customizer.js
I think that with some additions to the core customizer code we could remove the requirement for the customizer.js file for the most common use cases.
What I would like to suggest com
@BinaryMoon
BinaryMoon / hide-archive-prefix.php
Last active May 14, 2018 19:27
Hide WordPress Archive Prefix plugin
<?php
/**
* Plugin Name: Remove Archive Prefix
* Plugin URI: https://www.binarymoon.co.uk/
* Description: Hide the prefix displayed at the start of archive titles.
* Author: Ben Gillbanks
* Version: 1.0
*/
/**
@BinaryMoon
BinaryMoon / app.html
Last active April 5, 2017 15:49
merge javascript
---
---
/**
* Javascript code for https://www.binarysun.co.uk/
*/
{% include_relative bs_favorites.js %}
{% include_relative bs_fullscreen.js %}
@BinaryMoon
BinaryMoon / head.html
Created April 5, 2017 15:48
decache scripts and styles
<link rel="stylesheet" href="{{ "/assets/css/main.css" | relative_url }}?dc={{ site.time | date: '%y%m%d%k%M' }}">
<script src="{{ "/assets/scripts/app.js" | relative_url }}?dc={{ site.time | date: '%y%m%d%k%M' }}"></script>
@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 }}%;
@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 );