Skip to content

Instantly share code, notes, and snippets.

View BronsonQuick's full-sized avatar

Bronson Quick BronsonQuick

View GitHub Profile
@BronsonQuick
BronsonQuick / add_tinymce_custom_classes_with_backwards_compatibility.php
Last active August 29, 2015 14:01
Add TinyMCE custom classes to WordPress with backwards compatibility
<?php
Sometimes we want to give clients access to additional styles in TinyMCE. These functions also handle backwards compatibility with WordPress as TinyMCE 3 and TinyMCE 4 handle this differently
function sennza_mce_buttons( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
add_filter( 'mce_buttons_2', 'sennza_mce_buttons' );
function sennza_mce_before_init( $init_array ) {
@BronsonQuick
BronsonQuick / sennza_testimonials.php
Created March 9, 2014 06:00
Displaying CMB data example for JohnLion
<?php function sz_get_testimonials( $page_id ){
$testimonials = get_post_meta( $page_id, 'testimonial', false );
if ( $testimonials ) {
$testimonial_list = "\n<ul>\n";
foreach ( $testimonials as $testimonial ) {
$testimonial_image = false;
$testimonial_content = false;
$testimonial_list .= "\t<li class='row'>";
if ( $testimonial['testimonial-image'] ) {
$testimonial_image = wp_get_attachment_image( $testimonial['testimonial-image'], 'full', '', array( 'class' => 'columns small-3' ) );
@BronsonQuick
BronsonQuick / add_foundation_5_columns_to_wordpress_tinymce.php
Created February 21, 2014 00:07
A gist to show @jordesign how to add Foundation 5 columns into WordPress.
<?php
/**
* Pop this into your functions.php if you like :)
*
*/
function jordesigns_mce_buttons( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
add_filter( 'mce_buttons_2', 'jordesigns_mce_buttons' );
@BronsonQuick
BronsonQuick / post_thumbnail_html_foundation_wordpress.php
Created February 18, 2014 05:46
A gist to show how I am filtering post_thumbnail_html to output Foundations Interchange markup on www.sennza.com.au
<?php
/**
* We need to filter our post thumbnails so we can output them in a format that Foundations Interchange needs.
* We also need a fallback for no JavaScript
*
* @param $html
* @param $post_id
* @param $post_thumbnail_id
* @param $size
* @param $attr
@BronsonQuick
BronsonQuick / gist:8233624
Created January 3, 2014 06:08
A Sass mixin for rems & a pixel fallback for < IE8 and Opera Mini
/* Set up a variable for maths */
$doc-font-size: 16;
/* the font-size mixin */
@mixin font-size($size) {
font-size: 0px + $size;
font-size: 0rem + $size / $doc-font-size;
}
@BronsonQuick
BronsonQuick / sassy-mp6.scss
Created August 13, 2013 14:57
The main file for my MP6 sassing is this one. Y'all can work out the rest until I get it finished right? :P
@import "compass";
$base-font-family: "Open Sans", sans-serif;
$menu-base-color: #111;
$mid-menu-color: lighten( $menu-base-color, 6.5% );
$light-menu-color: lighten( $menu-base-color, 13.5% );
$menu-highlight-color: #682E93;
$active-plugins: lighten( $menu-highlight-color, 66.5% );
/* Need to revisit this */
$active-plugin-check-column: saturate( $menu-highlight-color, 50% );
@if $active-plugins == white {
@BronsonQuick
BronsonQuick / first_name_last_name_gravity_forms.php
Created July 15, 2013 02:01
Change Gravity Forms name labels from "First" and "Last" to "First Name" and "Last Name"
<?php
function sennza_change_first_name( $label, $form_id ){
return "First Name";
}
add_filter( 'gform_name_first', 'sennza_change_first_name', 10, 2 );
function sennza_change_last_name( $label, $form_id ){
return "Last Name";
}
add_filter( 'gform_name_last', 'sennza_change_last_name', 10, 2 );
@BronsonQuick
BronsonQuick / pending_comment_to_approved.php
Created July 4, 2013 12:31
Add an action for when a comment goes from pending to approved in WordPress. This will happen if Settings->Discussion is has 'Comment author must have a previously approved comment' checked in WordPress
<?php
add_action( 'comment_unapproved_to_approved', 'sennza_run_approved_comment_awesomeness', 10, 1 );
@BronsonQuick
BronsonQuick / change_buddypress_group_slugs_from_groups_to_teams.php
Created May 29, 2013 00:14
Change BuddyPress Group Slugs from Groups to "Teams"
<?php
/* Added to functions.php in the theme */
function ts_change_groups_slug(){
global $bp;
$bp->groups->root_slug = 'teams';
return $bp->groups->root_slug;
}
add_filter( 'bp_get_groups_slug', 'ts_change_groups_slug' );
add_filter( 'bp_get_groups_root_slug', 'ts_change_groups_slug' );
@BronsonQuick
BronsonQuick / gravity_forms_australian_formatted_address.php
Created May 13, 2013 01:57
Adds an Australian formatted Address dropdown to the Address field in Gravity Forms
function g8_aus_address( $address_types, $form_id ){
$address_types["australia"] = array(
"label" => "Australian",
"country" => "Australia",
"zip_label" => "Postcode",
"state_label" => "State",
"states" => array(
"NT" => "NT",
"ACT" => "ACT",
"NSW" => "NSW",