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 / 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 / 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 / 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 / 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 / .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,
# 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 / 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 ) {
@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 / functions.php
Last active October 24, 2016 10:11
WordPress Child Theme Example
<?php
function child_enqueue_parent_styles() {
wp_enqueue_style( 'child-parent-style', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'child_enqueue_parent_styles' );
@BinaryMoon
BinaryMoon / functions.php
Last active March 4, 2020 15:06
Register WordPress sidebars demo
<?php
/**
* Intitiate sidebars
*
* @link https://developer.wordpress.org/reference/functions/register_sidebar/
*/
function mytheme_widgets_init() {
// Sidebar.
register_sidebar(