Skip to content

Instantly share code, notes, and snippets.

View ptasker's full-sized avatar
:fishsticks:

Peter Tasker ptasker

:fishsticks:
View GitHub Profile
@ptasker
ptasker / functions-cheezies.php
Created January 3, 2012 15:21
Cheezcap settings created from a list of terms
/**
*
* Helper for the Cheezcap config array.
*
* Loops through the terms and categories on the site and creates Cheezcap options for them.
*
* Used to create Cheezcap options per category/taxonomy
*
* @param type $term
* @param type $slug
@ptasker
ptasker / gist:2960851
Created June 20, 2012 16:41
Codeigniter - Model get by FBID and Date
<?php
public function get_by_fbid( $fbid ) {
$where = "fbid = {$fbid} AND DATE_FORMAT(date_modified, \"%Y-%m-%d\") = CURDATE()";
$this->db->select( 'id' )
->from( 'entries' )
->where( $where );
$query = $this->db->get();
@ptasker
ptasker / gist:3006592
Created June 27, 2012 20:17
Useful Linux Commands
# Find text in files recursively and only display the file name
grep -H -r "search term" /filepath | cut -d: -f1
# Search in file for term and color them in result
egrep -iw --color=auto 'user|group' /etc/httpd/conf/http
@ptasker
ptasker / gist:3229687
Created August 1, 2012 18:41
Get attachments
<?php
/**
*
* Gets media attached to a post
*
*
* @global type $post
* @param type $post_id
* @return type array
* @todo revise method to be more flexible
@ptasker
ptasker / gist:3229701
Created August 1, 2012 18:43
Get attachments by slug
<?php
/**
*
* Gets the URL to a media item based on the media item's name (slug)
*
*
* @param type $slug
* @return type
*
*
@ptasker
ptasker / gist:3288142
Created August 7, 2012 18:36 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@ptasker
ptasker / gist:3288297
Created August 7, 2012 18:50
PHP Include all files in a directory
<?php
$the_dir = "/var/www/foo/bar/includes/";
foreach ( glob( $the_dir . '*.php' ) as $file )
{
require_once $file;
}
@ptasker
ptasker / gist:3369855
Created August 16, 2012 12:40 — forked from davidgtonge/gist:1227605
WPML Get homepage IDs
<?php
function get_wpml_home_ids(){
//Globalizse the $wpdb variable (instantiation of the wpdb class)
global $wpdb;
//Get the front-page id from the options table
$home_id = get_option('page_on_front');
//Run the query
@ptasker
ptasker / gist:3714647
Created September 13, 2012 14:27
Facebook Add App to Tab
https://www.facebook.com/dialog/pagetab?app_id=APP_ID&next=APP_HOSTED_URL
<div id="fb-root"></div>
<script type="text/javascript" src="//connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
FB.init({
appId: 'APPID', // App ID
channelUrl: '//example.com/channel.html', // Channel File
status: true,
cookie: true,
xfbml: true
});