Skip to content

Instantly share code, notes, and snippets.


Timothy Wood codearachnid

View GitHub Profile
View ko.extended.js
// This is now managed officially here:
// custom binding attrIf which will check the value of a specific observable boolean before add or not the attributes
ko.bindingHandlers.attrIf = {
update: function (element, valueAccessor, allBindingsAccessor) {
var h = ko.utils.unwrapObservable(valueAccessor());
var ifShow = ko.utils.unwrapObservable(h._if);
if (ifShow) {
ko.bindingHandlers.attr.update(element, valueAccessor, allBindingsAccessor);
} else {
for (var k in h) {
codearachnid / gist:9537604
Last active Aug 29, 2015
It seems that with WordPress 3.8.1 or greater has an issue with wp_get_attachment_metadata() it now throws an error (or on some servers no result) when trying to get the details of an attachment which is not an image.
View gist:9537604
$attachment_ids = (array) $attachment_ids;
$wp_upload_dir = wp_upload_dir();
$attachments = array();
foreach( $attachment_ids as $attachment_id ){
$attachment = wp_get_attachment_metadata( $attachment_id );
if( !empty( $attachment['file'] ) ){
$attachments[] = trailingslashit( $wp_upload_dir['basedir'] ) . $attachment['file'];
codearachnid / filter_widget_taxonomy_terms.php
Last active Aug 29, 2015
Filter widgets in sidebar to filter taxonomy terms by author when on the author template - the request:
View filter_widget_taxonomy_terms.php
* For updates to this code please use the latest here:
* @link
add_filter( 'widget_tag_cloud_args', 'filter_categories_by_author' );
add_filter( 'widget_categories_dropdown_args', 'filter_categories_by_author' );
codearachnid / theme-unit-test-data.xml
Created Mar 21, 2014
WordPress theme unit test data with visual variations
View theme-unit-test-data.xml
<?xml version="1.0" encoding="UTF-8"?>
This is a WordPress eXtended RSS file generated by WordPress as an export of your site.
It contains information about your site's posts, pages, comments, categories, and other content.
You may use this file to transfer that content from one site to another.
This file is not intended to serve as a complete backup of your site.
To import this information into a WordPress site follow these steps:
1. Log in to that site as an administrator.
2. Go to Tools: Import in the WordPress admin panel.
codearachnid / custom_limit_gform_is_duplicate.php
Created Mar 26, 2014
Allow a certain amount of duplicates in a Gravity From by field before kicking back a failure check.
View custom_limit_gform_is_duplicate.php
add_filter( 'gform_is_duplicate', 'custom_gform_is_duplicate', 10, 4 );
function custom_gform_is_duplicate( $count, $form_id, $field, $value ){
global $wpdb;
$lead_detail_table_name = GFFormsModel::get_lead_details_table_name();
$lead_table_name = GFFormsModel::get_lead_table_name();
$sql_comparison = "ld.value=%s";
codearachnid / posts.xml
Created Mar 27, 2014
Export your Expression Engine 1.x content into WordPress compatible importable XML.
View posts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!-- generator="WordPress/3.3.2" created="2012-06-25 23:09" -->
<rss version="2.0"
codearachnid / gf_notification_debug.php
Created Apr 2, 2014
Debug Gravity Forms: Notification Attachments
View gf_notification_debug.php
Plugin Name: Gravity Forms: Notification Attachments Debug
Plugin URI:
Description: Debug the addon for Gravity Forms to add attachments to notification emails
Version: 1.0
Author: Timothy Wood (@codearachnid)
Author URI:
codearachnid / deviceBaseURL.js
Created Apr 24, 2014
A quick way to get the local file's url (used on phonegap)
View deviceBaseURL.js
var tempElement = document.createElement("a");
tempElement.setAttribute("href", ".");
var deviceBaseURL = tempElement.href;
codearachnid / remove-co-authors-plus-column.php
Last active Aug 29, 2015
Remove the "Authors" column from Co Authors Plus for a post type list in the admin
View remove-co-authors-plus-column.php
add_action( 'admin_init', 'coauthors_cleanup_admin_init', 100 );
function coauthors_cleanup_admin_init(){
global $coauthors_plus, $pagenow;
if( 'edit.php' == $pagenow && 'post' == $_GET['post_type']){
remove_filter( 'manage_posts_columns', array( $coauthors_plus, '_filter_manage_posts_columns' ) );
codearachnid / toRadians.js
Last active Aug 29, 2015
Convert degrees to radians
View toRadians.js
* Convert degrees to radians
* @author Timothy Wood @codearachnid
* @link
* @example
var latitude = 38.68551;
var longitude = -96.503906;
var latitude_radian = latitude.toRadians();
var longitude_radian = longitude.toRadians();