Skip to content

Instantly share code, notes, and snippets.

Steve Taylor gyrus

Block or report user

Report or block gyrus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View custom_post_type_authors.php
<?php
add_action( 'cmb2_init', 'pilau_cmb2_custom_fields' );
/**
* Register custom fields
*/
function pilau_cmb2_custom_fields() {
// Loop through CPTs
foreach ( get_post_types( array( '_builtin' => false ), 'objects' ) as $cpt ) {
@gyrus
gyrus / pilau-multiply-posts.php
Last active Aug 29, 2015
Allows the artificial multiplication of posts in WordPress queries for testing purposes.
View pilau-multiply-posts.php
<?php
/**
* Allow the multiplication of posts in query results for testing purposes.
*
* In the query args, set pilau_multiply to the number you want the posts multiplying by.
* NOTE: If using get_posts() instead of WP_Query, you will need to set suppress_filters to true.
*/
add_filter( 'the_posts', 'pilau_multiply_posts', 10, 2 );
function pilau_multiply_posts( $posts, $query ) {
@gyrus
gyrus / pilau-list-dimensions.js
Created Aug 9, 2014
Use jQuery to calculate the heights of each row in a list, and the total number of rows (even if the list items are floated)
View pilau-list-dimensions.js
/**
* For a list, calculate how many rows, height of each row
*
* @param {object} l The list jQuery object
* @return {object}
*/
function pilau_list_dimensions( l ) {
var d = {
@gyrus
gyrus / wp-override-image-sizes
Created Feb 19, 2015
Override WordPress image sizes defined in admin
View wp-override-image-sizes
<?php
add_filter( 'option_thumbnail_size_w', function() { return 176; } );
add_filter( 'option_thumbnail_size_h', function() { return 210; } );
add_filter( 'option_thumbnail_crop', function() { return 1; } );
add_filter( 'option_medium_size_w', function() { return 400; } );
add_filter( 'option_medium_size_h', function() { return 265; } );
add_filter( 'option_medium_crop', function() { return 1; } );
add_filter( 'option_large_size_w', function() { return 746; } );
add_filter( 'option_large_size_h', function() { return 372; } );
@gyrus
gyrus / pilau_ie10classes.js
Created Apr 8, 2015
jQuery HTML classes for IE 10+
View pilau_ie10classes.js
/*
* A hack to add classes to the HTML element (a la Paul Irish) for IE 10+
* IE 10 and over no longer support conditional classes. However, sometimes
* you still need to target IE above 9!
*/
jQuery( document ).ready( function( $ ) {
var html = $( html );
if ( /MSIE 1[01]\.\d+;/.test( navigator.userAgent ) || /Trident/.test( navigator.userAgent ) ) {
html.addClass( 'ie' );
if ( /MSIE 10\.\d+;/.test( navigator.userAgent ) ) {
@gyrus
gyrus / pilau_wp_head.php
Last active Aug 29, 2015
Wrapper for wp_head() which manages SSL
View pilau_wp_head.php
/**
* Wrapper for wp_head() which manages SSL
*
* @uses wp_head()
* @param bool $ssl
* @return void
*/
function pilau_wp_head( $ssl = false ) {
if ( ! $ssl || WP_LOCAL_DEV ) {
@gyrus
gyrus / .bashrc
Last active Aug 29, 2015
Linux .bashrc aliases
View .bashrc
# Edit the hosts file
alias edit-hosts='sudo gedit /etc/hosts'
# Edit this file
alias edit-bash='sudo gedit ~/.bashrc'
# Apply changes in this file to current terminal session
alias refresh-bash='source ~/.bashrc'
# Switch to local web root
@gyrus
gyrus / free.php
Created Jun 18, 2015
Free custom filter for Events Calendar Pro Filter Bar
View free.php
<?php
/**
* Free? filter
*
* @package Young_Hackney
* @since 0.1
*/
class TribeEventsFilter_Free extends TribeEventsFilter {
public $type = 'checkbox';
@gyrus
gyrus / admin.css
Created Jun 22, 2015
Hide recurring instances in admin for The Events Calendar WordPress plugin
View admin.css
// Optional - a bit of spacing
.filter-checkbox {
margin: 0 .8em;
}
View cmb-select-with-optgroups.php
<?php
function cmb_opt_groups( $args, $defaults, $field_object, $field_types_object ) {
// Only do this for the field we want (vs all select fields)
if ( '_cmb_option_field' != $field_types_object->_id() ) {
return $args;
}
$option_array = array(
'Group 1' => array(
You can’t perform that action at this time.