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 / dabblet.css
Created December 7, 2012 14:49
Textured stitched CSS3 box - with a kitten
/**
* Textured stitched CSS3 box - with a kitten
*/
.stitched {
display:block;
position:relative;
width:200px;
height:200px;
margin:20px;
@BinaryMoon
BinaryMoon / matty-theme-quickswitch.php
Created October 20, 2013 12:12
An updated version of http://wordpress.org/plugins/matty-theme-quickswitch/ that allows you to switch themes from the front end AND the backend.
<?php
/*
Plugin Name: Matty Theme QuickSwitch
Plugin URI: http://matty.co.za/
Description: Adds a quick theme switcher to the WordPress Admin Bar, aimed at speeding up rapid theme switching during theme development and maintenance.
Author: Matty
Author URI: http://matty.co.za/
Version: 1.2.3
Stable tag: 1.2.3
License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@BinaryMoon
BinaryMoon / wordpress-custom-sidebar.php
Created May 15, 2015 14:19
Dynamically create sidebars based upon page templates being used.
<?php
/**
* Dynamically register sidebar for pages that use specified template
*/
function showcase_register_page_sidebars() {
// Find all pages that use template with dynamic sidebar
// ideally this would be done in the admin only since it's creating an additional query that's not needed on most pages
$query = new WP_Query( array(
@BinaryMoon
BinaryMoon / jetpack-related-posts-test.php
Last active December 2, 2019 06:45
Display Jetpack Related Posts in a local environment. Note that the thumbnails won't load - but it's good enough to be able to test styles
@BinaryMoon
BinaryMoon / wp_human_time_diff.php
Created May 5, 2016 21:00
Human Time Difference Function for WordPress
<?php
/**
* Display the post time in a human readable format
*
* @return string
*/
function carmack_human_time_diff() {
$post_time = get_the_time( 'U' );
$time_now = date( 'U' );
@BinaryMoon
BinaryMoon / author-bio.php
Created September 2, 2016 20:48
Alternate version of author-bio.php - allows the ability to add a function as a callback for the author bio layout
<?php
/**
* The function to display Author Bio in a theme.
*/
function jetpack_author_bio() {
// If the theme doesn't support 'jetpack-content-options', don't continue.
if ( ! current_theme_supports( 'jetpack-content-options' ) ) {
return;
}
@BinaryMoon
BinaryMoon / author-bio.php
Created September 2, 2016 21:01
Alternate version of author-bio.php that separates the author bio into a separate function so that the same code can be used in other template files
<?php
/**
* The function to display Author Bio in a theme.
*/
function jetpack_author_bio() {
// If the theme doesn't support 'jetpack-content-options', don't continue.
if ( ! current_theme_supports( 'jetpack-content-options' ) ) {
return;
}
@BinaryMoon
BinaryMoon / blog-display.php
Created September 12, 2016 22:31
Fixes to excerpt preview in blog-display.php
<?php
/**
* The functions to display Content or Excerpt in a theme.
*/
/**
* If the theme doesn't support 'jetpack-content-options', don't continue.
*/
if ( ! current_theme_supports( 'jetpack-content-options' ) ) {
return;
@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(
@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' );