Skip to content

Instantly share code, notes, and snippets.

View carmichaelize's full-sized avatar

Scott Carmichael carmichaelize

View GitHub Profile
angular.module('myApp.services', [])
.service('$_http', function($http, $q, $compile) {
//Serialize Parameters
var $param = function(obj){
var query = '',
name, value, fullSubName, subName, subValue, innerObj, i;
for(name in obj){
@carmichaelize
carmichaelize / wp_api_query.php
Last active August 29, 2015 14:00
Wordpress Transients & API Calls
<?php
//Get transient data
$data = get_transient( 'data_key' );
//Check transient data exists
if(!$data){
//Query API
@carmichaelize
carmichaelize / twitter_regex.php
Last active September 17, 2017 08:54
Twitter Links, Mentions and Hashtag Regex
<?php
//Urls
$tweet = preg_replace('/(http[^\s]+)/', '<a target="_blank" class="tweet-link" href="$1">$1</a>', $tweet->text);
//Mentions
$tweet = preg_replace('/\@([a-zA-Z1-9]+)/', '<a title="@$1" target="_blank" href="https://twitter.com/$1" class="tweet-user">@$1</a>', $string);
//Hashtags
$tweet = preg_replace('/#([a-zA-Z1-9]+)/', '<a title="#$1" target="_blank" href="https://twitter.com/search?q=%23$1&src=hash" class="tweet-hashtag">#$1</a>', $string);
@carmichaelize
carmichaelize / custom_metabox.php
Last active August 29, 2015 14:00
Wordpress Metabox Wrapper
<?php
class custom_metabox {
//Custom metabox key
public $key = 'meta_box_key';
//Custom metabox options
public $options = array(
'post_types' => get_post_types(),
@carmichaelize
carmichaelize / custom_post_type.php
Last active August 29, 2015 14:00
Wordpress Custom Post Type Wrapper
<?php
class custom_post_type {
//Custom post type name
public $post_type_name = 'name';
//Custom metabox key
public $key = $this->post_type_name = 'key';
@carmichaelize
carmichaelize / shortcode.php
Last active August 29, 2015 14:00
Wordpress Shortcode Wrapper
<?php
class shortcode {
//Shortcode name
public $name = 'shortcode_name'
//Default attributes
public $args = array();