Skip to content

Instantly share code, notes, and snippets.

View benhuson's full-sized avatar

Ben Huson benhuson

View GitHub Profile
@benhuson
benhuson / list-pages-shortcode-index.php
Last active August 29, 2015 14:04
List Pages Shortcode Index - Create alphabetically indexes using the List Pages Shortcode plugin (http://wordpress.org/extend/plugins/list-pages-shortcode/)
<?php
/*
Plugin Name: List Pages Shortcode Index
Plugin URI: https://gist.github.com/benhuson/9c419282d8e05fff6eeb
Description: Add-on for the <a href="https://wordpress.org/plugins/list-pages-shortcode/">List Pages Shortcode</a> plugin.
Author: Ben Huson
Version: 0.1
Author URI: https://github.com/benhuson
*/
@benhuson
benhuson / my_plugin_row_meta.php
Created May 1, 2014 17:24
Add a link to your GitHub repo and translation link to your WordPress plugin.
<?php
/**
* Plugin Row Meta
*
* Adds GitHub and translate links below the plugin description on the plugins page.
* Replace references to 'my-plugin' to reflect your plugin folder and file name.
* Update the GitHub Repo and Translation links.
*
* @param array $plugin_meta Plugin meta display array.
/* Nested Ordered List */
ol {
counter-reset: ol
}
li {
display: block
}
@benhuson
benhuson / wp-config.php
Created April 1, 2014 16:49
Sample snippets for wp-config.php
<?php
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
define( 'WP_DEBUG', true );
@benhuson
benhuson / .htaccess
Last active September 9, 2015 15:52
.htaccess examples
# Redirect to fully qualified domain if different
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com
RewriteRule (.*) http://www.example.com%{REQUEST_URI}
</IfModule>
@benhuson
benhuson / ios7-safari-height-issue
Last active April 22, 2016 10:10
Fix iOS 7 iPad Safari Landscape innerHeight/outerHeight layout issue
/**
* Add ipad IOS7 Classes
* Allows us to temporariliy try to fix the slight scroll 100% hack.
* http://stackoverflow.com/questions/19012135/ios-7-ipad-safari-landscape-innerheight-outerheight-layout-issue
*/
if (navigator.userAgent.match(/iPad;.*CPU.*OS 7_\d/i)) {
$('html').addClass('ipad ios7');
}
/**
@benhuson
benhuson / users2csv.php.patch
Last active December 31, 2015 20:39
Patch for Users 2 CSV WordPress plugin.
Index: users2csv.php
===================================================================
--- users2csv.php (revision 277117)
+++ users2csv.php (working copy)
@@ -26,7 +26,7 @@
if ( is_admin() ) {
- if ($_GET['page'] == "users2csv.php") {
+ if ( isset( $_GET['page'] ) && $_GET['page'] == 'users2csv.php' ) {
var ipad_version = 0;
window.ondevicemotion = function(event) {
if (navigator.platform.indexOf("iPad") != -1) {
ipad_version = 1;
if (event.acceleration) ipad_version += window.devicePixelRatio;
}
window.ondevicemotion = null;
get_ipad_version();
}
@benhuson
benhuson / custom-posts-order
Last active December 25, 2015 21:09
WordPress custom order for main query
<?php
/**
* Post Order
*/
function product_orderby( $query ) {
if ( $query->is_main_query() && ( is_post_type_archive( 'custom_post_type_name' ) ) ) {
$query->set( 'order', 'ASC' );
$query->set( 'orderby','menu_order' );
}
@benhuson
benhuson / js-clickable-block.js
Created May 29, 2013 08:35
JS Clickable Block
jQuery(".clickable-block").click(function(){
window.location = jQuery(this).find('a').attr('href');
return false;
});