Skip to content

Instantly share code, notes, and snippets.

View benhuson's full-sized avatar

Ben Huson benhuson

View GitHub Profile
@benhuson
benhuson / gist:2576426
Created May 2, 2012 13:09
Useful CSS
/* Prevent text scaling on rotate for iPad/iPhone */
html { -webkit-text-size-adjust: none; }
@benhuson
benhuson / gist:2576414
Created May 2, 2012 13:06
Fix scale on rotate issue on iPad/iPhone
/**
* Fix scale on rotate issue
*/
if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) {
var viewportmeta = document.querySelector('meta[name="viewport"]');
if (viewportmeta) {
viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0';
document.body.addEventListener('gesturestart', function () {
viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
}, false);
@benhuson
benhuson / jquery.touchcarousel-1.0.patch.js
Created March 28, 2012 18:00
TouchCarousel - Detach
/* Detach carousel - same as destroy but content is not removed */
detach: function() {
this.stopAutoplay();
this._itemsWrapper.unbind(this._downEvent);
$(document).unbind(this._moveEvent).unbind(this._upEvent);
$(window).unbind(this._resizeEvent);
if(this.settings.keyboardNav) {
$(document).unbind("keydown.touchcarousel");
}
if (this._dragContainer.parent().hasClass('touchcarousel-wrapper')) {
@benhuson
benhuson / gist:2043878
Created March 15, 2012 12:00
WPEC normal email fields on wpsc-shopping_cart_page.php
If you remove the following code from the wpsc-shopping_cart_page.php template, I think it works normally:
Around line 358:
<?php
}elseif( $wpsc_checkout->checkout_item->unique_name == 'billingemail'){ ?>
<?php $email_markup =
"<div class='wpsc_email_address'>
<p class='" . wpsc_checkout_form_element_id() . "'>
<label class='wpsc_email_address' for='" . wpsc_checkout_form_element_id() . "'>
@benhuson
benhuson / get_the_term_list_breadcrumbs.php
Created February 17, 2012 14:55
get_the_term_list_breadcrumbs() - Same as get_the_term_list() but outputs a terms parents as part of the link.
/**
* Get the Term List Breadcrumbs
* Same as get_the_term_list() but outputs a terms parents as part of the link.
* Useful when you have many subcategories all with the same name.
*/
function get_the_term_list_breadcrumbs( $id = 0, $taxonomy, $before = '', $sep = '', $after = '', $breadcrumb_sep = ' &rarr; ' ) {
$terms = get_the_terms( $id, $taxonomy );
if ( is_wp_error( $terms ) )
@benhuson
benhuson / Post_Taxonomy_Columns_And_Filter
Created February 17, 2012 11:21
Framework for adding taxonomy filter and column to WordPress manage post admin pages.
<?php
class Post_Taxonomy_Columns_And_Filter {
/**
* Constructor
*/
function Post_Taxonomy_Columns_And_Filter() {
add_filter( 'manage_edit-mycustomposttype_columns', array( $this, 'manage_mycustomposttype_columns' ) );
add_action( 'manage_mycustomposttype_posts_custom_column', array( $this, 'show_mycustomposttype_columns' ) );
@benhuson
benhuson / class-frontend.php
Created February 3, 2012 15:48
WordPress SEO plugin patch
<?php
class WPSEO_Frontend {
function __construct() {
$options = get_wpseo_options();
add_action( 'wp_head', array(&$this, 'head'), 1, 1 );
remove_action( 'wp_head', 'rel_canonical' );