Skip to content

Instantly share code, notes, and snippets.

@dalethedeveloper
dalethedeveloper / gist:1222205
Created September 16, 2011 14:11
Implementing rel="next" and rel="prev" on Wordpress
/*
This will work on WP 2.7.0 on up on the commonly used get_xxxxxxx_posts_link call.
From Google:
http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html
*/
add_filter('next_posts_link_attributes', create_function('$attr','return $attr.\' rel="next" \';'));
add_filter('previous_posts_link_attributes', create_function('$attr','return $attr.\' rel="prev" \';') );
@dalethedeveloper
dalethedeveloper / gist:1264836
Created October 5, 2011 16:07
jQuery InViewToo Plugin - Viewport Triggers
/*
jQuery InViewToo Plugin to add triggers for elements entering/leaving the viewport
Not entirely complete, fully featured, or documented...but functional!
Fiddle Away!
http://jsfiddle.net/dalesaurus/CkFUB/
Inspired by
http://www.appelsiini.net/projects/lazyload
@dalethedeveloper
dalethedeveloper / gist:1265499
Created October 5, 2011 19:53
Very Lazy Loading of Facebook Connect with jQuery
/*
Use jQuery to load FB Connect javascript asynchronously, then trigger manual parsing of individual XFBML tags
*/
window.fbAsyncInit = function() {
FB.init({channelUrl:'http://YOUR_SITE_URL.HERE/channel.html',xfbml: false,logging:false,status:false});
};
(function() {
jQuery(document).ready(function() {
jQuery.getScript('http://connect.facebook.net/en_US/all.js', function(){
var parseXFBML = function() {
@dalethedeveloper
dalethedeveloper / gist:1444480
Created December 7, 2011 20:26
Wordpress - Cross Taxonomy Tag List Query
<?php
/**
Echo a list of tags terms for posts that are also have a $where_tax of $where_slug
Queries added to transient cache for performance
Note: Using the slug for a Taxonomy in $where_slug for simpler query
Tested up to WP 3.3, drop it in your functions.php
Example: Get a tag list for Posts in the 'News' Category
tags_by_other_taxonomy('news');
@dalethedeveloper
dalethedeveloper / gist:1474525
Created December 13, 2011 23:54
Generic WP Plugin Admin Menu Implementation - with AJAX!
<?php
/*
Plugin Name: Generic Menu
Plugin URI: http://example.com/
Description: Move things
Author: dalethedeveloper
Version: 0.1
*/
new myadmin_generic();
@dalethedeveloper
dalethedeveloper / gist:1793789
Created February 10, 2012 22:55
Safely wrap jQuery when multiple versions are present on a page
<!--
For testing how multiple versions of jQuery interact on a page,
see http://jsfiddle.net/dalesaurus/5TgkG/
-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">window.jQuery || document.write('<script src="/js/jquery-1.7.1.min.js"><\/script>')</script></script>
<script type="text/javascript">
var jQuery171 = window.jQuery;
jQuery171(document).ready(function($){
// Do work, son!
@dalethedeveloper
dalethedeveloper / gist:3823530
Created October 2, 2012 21:48
WordPress fetch custom Taxonomy Terms with Posts
/**
Get all terms in a Taxonomy including associated posts
Like get_objects_in_term() for all terms or get_terms() that includes posts
@$tax string Taxonomy to fetch (Default "post_tag", must be a slug)
@$post_type string Post type to use (Default "post")
@$query_args string Additional Query Args to use when querying objects (Default: '', must be string form, eg 'order=ASC&post_status=published')
@$return_ids bool Return just Post IDs in $return->posts instead of complete post Objects (Default: false)
*/
function get_objects_in_taxonomy($tax = 'post_tag', $post_type = 'post', $query_args = '', $return_ids = false ) {
@dalethedeveloper
dalethedeveloper / gist:3305558
Created August 9, 2012 16:12
RSVP button for Facebook Event using CSS / encoded image
<!-- http://tinkerbin.com/jkItQEwh -->
<a href="https://www.facebook.com/events/331218348435" class="fb_rsvp" target="_blank" title="RSVP on Facebook">RSVP</a>
<style type="text/css">
a.fb_rsvp {
background: #ECEEF5 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAAASCAYAAADLw4ffAAAAAXNSR0IArs4c6QAAA0ZJREFUSA3VVXtIk1EU/21q6h665ZypU9SgtEwt0hL6JyICiQgRiwgKCiPor/qjiKiECCIEA+lB2UOMgiyo6GVkLxMniuarfGe6pXNu6l5uPta9V78vc5u5CMwL+75zzj3n3N8953e+CfQGixOLdAkXKW4Ge1GD952r8rVftGhq00FnMOPo/k1zuS7InkfwLV16FNyt5EFRfWWsgtf/B0HgaWAPnHrkgq/wXKaLbaZhYmISjW39vEkq9kdMpBxCoYC3aXUj6NObEB+nhCjAj9m7tUMIkvhDHhTI+/X2DSOQ7FN7c7tuyk7SRIfLeL9/ynm7YxzXS6rR1j3IfmXqTpzML4XJYmeHXyqqwOuKdgLejPw7n1D5uYfZO74P4sWHVh44FW6QPDb7GKy2MRQ+nMrZSrp/5Z4axU/rmK9H2vyWyQtFIlqCrG2JfETxkzpUN2qwIkYBx9g49u1cx/bSU6Lx4GUDNiZHIXWNCrmXy7A7I4l1STdoxuSkE6qwYAybRkE7yOUcJ909kfcKmVtX468qTynljlY84mnBbHXgB6FIhFIKWVAANDoTq/CAwcJan5OdxjwpuKhlwfjaNcD0miYt0pJUs9MxnVKOLn8/H3isPOU3B1AmDUDe8QwW9KeHYdiKMwVvmJtx2Ia4KDmrukAgwOnDm0GpdPW+GqOEYrSaaxMimG96cjTU9T1YtVyJmiYNcrJT
@dalethedeveloper
dalethedeveloper / gist:4560788
Created January 17, 2013 23:13
More robust Google Analytics tracking for Zoey (http://blog.angeloff.name/zoey/), in particular treating single-page <article> tags as pageviews. Tucking the view under the /mobile/[panel id] for simpler segment/search.
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22762790-1']);
// DELAY _gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
@dalethedeveloper
dalethedeveloper / gist:4656838
Created January 28, 2013 16:13
Rollback WordPress 3.5's jQuery version to 1.7.2 for plugins that haven't been migrated to 1.8.3 yet. Be aware there may be unintended consequences of using this, particularly in the WP Admin. You will need to call jQuery.noConflict() early as well ref: http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers
function rollback_jquery() {
wp_deregister_script('jquery');
wp_enqueue_script('jquery-1.7.2','http://code.jquery.com/jquery-1.7.2.min.js');
}
add_action('wp_enqueue_scripts','rollback_jquery',100);