Skip to content

Instantly share code, notes, and snippets.

@sloped
sloped / addthis_async_load.js
Created July 2, 2012 21:42
Addthis Async and conditional load script
if(jQuery('.namespace_addthis').length > 0) {
jQuery.ajaxSetup({cache: true});
jQuery(window).load(function(){jQuery.getScript('//s7.addthis.com/js/250/addthis_widget.js#pubid=', true);});
jQuery(".namespace_addthis").each(function() {
jQuery(this).html('<div class="addthis_toolbox addthis_default_style addthis_32x32_style" ><a class="addthis_button_facebook"></a><a class="addthis_button_twitter"></a><a class="addthis_button_email"></a> <a class="addthis_button_compact"></a><a class="addthis_counter addthis_bubble_style"></a></div>');
})
}
@sloped
sloped / gaaware_track.js
Created June 28, 2012 13:02
GAAware tracking code using data attributes and class
/*
GA Aware Track Event Syntax
gaAware.track_event('Category', 'Action', 'Label', Count (1));
Data Attribute to attach to item to track. May be worth breaking these into seperate data attributes to make things more semantic. Might also be able to swap the quote types, but haven't tested yet.
data-tracking='{"category":"x","action":"x","label":"x"}''
*/
var gaAware = jQuery(document).gaaware({
UA: ['UA-2629988-12'],
@sloped
sloped / wp_dashboard_admin_bar.php
Created March 19, 2012 16:24
Edit Wordpress Dashboard and Admin Bar
<?php
function admin_bar_edit() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('comments');
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_menu('new-content');
global $current_user;
get_currentuserinfo();
$args = array( 'author' => $current_user->ID, 'post_type' => 'food_trucks', 'posts_per_page' => -1);
query_posts( $args );
@sloped
sloped / paging.php
Created March 19, 2012 16:21
Bootstrap Paging and Wordpress
<?php
//Use this function to create pagingation links that are styleable with Twitter Bootstrap
function paging() {
global $wp_query;
$total_pages = $wp_query->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
@sloped
sloped / fb_head.php
Created March 19, 2012 16:18
Open Graph Tags Wordpress
<?php
// Outputs the appropriate tags for Facebook Open Graph. Call using wp_head() action hook. Could be customized using conditional template tags for pages/posts/custom posts.
function fb_metatags() { ?>
<meta property="og:title" content="Page or Site Title" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://url.com" />
<meta property="og:image" content="**url for image, could use wp-thumbnails here**" />
<meta property="og:site_name" content="Site Title" />
<meta property="fb:admins" content="#######" />
@sloped
sloped / post_by_current_author.php
Created March 19, 2012 16:14
Only Authored Posts Function Wordpress
<?php
/* Function to only display posts that are authored by the current user. Use capabilities to limit who is affected by this. Will not change post count list on page which can be confusing. Call using pre_get_posts() action hook
*/
function posts_by_current_author($query) {
global $pagenow;
if( 'edit.php' != $pagenow || !$query->is_admin )
return $query;
@sloped
sloped / remove_rel_links.php
Created March 19, 2012 16:10
Remove relational links from Wordpress wp_head()
@sloped
sloped / extendAccessToken.php
Created March 5, 2012 20:43
Simple Function to add to Facebook's facebook-php-sdk to grab an extended token for a user who has been authorized. Should be used when extending the BaseFacebook Class
<?php
function extendAccessToken() {
try {
// need to circumvent json_decode by calling _oauthRequest
// directly, since response isn't JSON format.
$access_token_response =
$this->_oauthRequest(
$this->getUrl('graph', '/oauth/access_token'),
$params = array('client_id' => $this->getAppId(),