Skip to content

Instantly share code, notes, and snippets.

@stephenharris
stephenharris / description.md
Last active August 29, 2015 14:03
Automated generation of 'colour schemed' stylesheets from less files.

Description of problem

You have a directory (colour-scheme/) containing .less (each defining a different colour scheme). For each of those files (call it scheme-x.less), compile it with the "core" .less file(s) (stored elsewhere) to create style-x.css.

Preferably, by adding a .less file to colour-scheme/ directory and running a grunt task, the appropriate style-?.css should be created. That is, no editing of Gruntfile.js is required.

Directory layout is below.

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//<?php get_bloginfo('name'); ?>//NONSGML Events //EN
<?php
// Loop through events
if ( have_posts() ):
$now = new DateTime();
$dtstamp =$now->format('Ymd\THis\Z');
$UTC_tz = new DateTimeZone('UTC');
@stephenharris
stephenharris / booking-confirmed-message.php
Created November 13, 2013 14:21
How to modify the "booking confirmed" messages, appearing on a booking form after booking has been complete.
<?php
/**
* IMPORTANT
*
* There are likely to be improvements to this in 1.5. The method below will still work after 1.5, but an
* alternative method is likely to offer improvements such as being able to use 'merge tags' in the booking
* confirmation message.
*
* A link shall be posted here to the improved API
**/
@stephenharris
stephenharris / style.css
Created September 20, 2013 12:41
Demonstration of how to customise the event list widget. Provides an example template with CSS styling, as used in the Omega theme (http://wp-event-organiser.com/demo/).
/**
* This should be added to your theme's style.css
*/
.eo-events-widget{ font-size: 14px }
.eo-events-widget li{ overflow:hidden;}
.eo-events .eo-date-container{ color:white;float:left;;text-align: center;width: 35px;line-height: 1.3; margin:0px 5px; }
.eo-events .eo-date-month{ margin: 0px;display: block;font-size: 14px;font-variant: small-caps;color: white;letter-spacing: 3.2px;text-align: center;}
.eo-events .eo-date-day{ display: block;margin: 0px;border: none;font-size: 20px; }
.eo-events .eo-date-container{ background: #1e8cbe}
.eo-events .eo-date-day{ background: #78c8e6}
@stephenharris
stephenharris / eo-theme-direct.php
Created September 11, 2013 19:01
Register a template location with Event Organiser for your theme
<?php
/**
* Registers the directory "[child-theme-dir]/event-organiser" as a template location for
* Event Organiser. EO will look there when looking for the plug-in template files (e.g. single-event.php, archive-event.php, etc )
*
*/
function mytheme_register_eventorganiser_stack( $stacks ){
//$stacks is an array of (absolute) directory paths. EO will look in the order
//in which they appear in the array
@stephenharris
stephenharris / pre-tags-in-comments.php
Created August 12, 2013 15:07
Allow pre tags in comments
<?php
/**
* Allow 'pre' tags in comments.
* This is not by default allowed for users who cannot publish 'unfiltered_html'.
* Maybe this should go in WP-MarkDown?
*
*/
add_filter( 'wp_kses_allowed_html', 'myprefix_allow_pre_tags_in_comments', 10, 2 );
function myprefix_allow_pre_tags_in_comments( $tags, $context ){
if( 'pre_comment_content' == $context ){
@stephenharris
stephenharris / bbpress-kses.php
Last active February 3, 2020 08:44
By default bbpress can be quite strict on the HTML it allows in posts (tags are whitelisted). The following loosens those restrictions and is taken from this post: http://buddypress.org/support/topic/tutorial-allow-more-html-tags-in-bp-forum-topics/
<?php
function myprefix_kses_allowed_tags($input){
return array_merge( $input, array(
// paragraphs
'p' => array(
'style' => array()
),
'span' => array(
'style' => array()
),
@stephenharris
stephenharris / kill-the-bot.php
Last active December 19, 2015 15:58
A really simple method of dealing with brute-force attacks. This is not about securing yourself from these attacks - it's stopping them wasting your server resources when they patently won't work.
<?php
/**
* A really simple method of dealing with brute-force attacks.
* This is not about securing yourself from these attacks - it's stopping them wasting your
* server resources when they patently won't work.
*
* Put this at the very top of your wp-config.php. Add other banned usernames as desired.
* You may wish to prevent users from registering them.
*/
<?php
/**
* An implementation of the AES cipher (CBC mode).
* For reference http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
*
* @author Stephen Harris ([email protected])
* @license GPL
*
* Example usage:
@stephenharris
stephenharris / get_the_parent_terms.php
Created June 13, 2013 10:32
Get taxonomy terms of a post who have a child term also associated with a post.
<?php
/**
* Returns a term IDs of terms that are associated with a post, and who have
* child terms also associated with the post.
*
* Please note, 'parent' is a slight misnomer. If you have category structure:
* Cat A > Sub-Cat B > Sub-Sub-Cat C
* and a post belongs to A and B, but not C. 'B' is not considered a parent term
* for this post.
*