Skip to content

Instantly share code, notes, and snippets.

@joeyblake
joeyblake / gist:1472625
Created December 13, 2011 15:49
simple php form mail
<?php
/* These are the variable that tell the subject of the email and where the email will be sent.*/
$emailSubject = 'Customer Has a Question!';
$mailto = 'you@youremail.com';
/* These will gather what the user has typed into the fieled. */
$nameField = $_POST['name'];
@joeyblake
joeyblake / gist:1566752
Created January 5, 2012 19:19
get_bitly_link
function get_bitly_link($post_id){
$post = get_page($post_id);
if($post->post_status == "published" || 1 == 1){
if(false === ($short_link = get_post_meta($post_id,'bitly_link',true))){
$http = _wp_http_get_object();
$args['login'] = self::BITLY_USERNAME;
$args['apikey'] = self::BITLY_APIKEY;
$args['longUrl'] = get_permalink($post_id);
if(is_wp_error($response = $http->request('https://api-ssl.bitly.com/v3/shorten?'.http_build_query($args),array('method'=>'GET')))){
return $response;
@joeyblake
joeyblake / hostfix
Created February 27, 2012 16:13
Shell script for cleaning/resetting /etc/hosts files messed up by MAMP Pro
#!/bin/bash
# copy this file to /usr/sbin
# if you have other hosts entries that you would not like to lose, make sure they get added to the hosts.mamp.bak file
cat /etc/hosts.mamp.bak > /etc/hosts
echo 'clean!'
<?php foreach ( $recipe_vars['instructions'] as $instruction ) { ?>
<p itemprop="recipeInstructions" >
<?php
if ($instruction['image_id'] != ""){
$inst_image = wp_get_attachment_image_src( $instruction['image_id'], "medium", false );
echo "<img src='{$inst_image[0]}' style='float:left;' /> ";
}
if (count($instruction['text']) > 1 ) {
echo '<ol>';
foreach ($instruction['text'] as $numbered_inst ){
@joeyblake
joeyblake / gist:2854349
Created June 1, 2012 18:50 — forked from coreyweb/gist:2718955
WordPress Popular Comments
<?php
/**
* Display a list of the 10 most commented posts (WordPress)
* @author Corey Brown https://github.com/coreyweb
* @author Aaron Collegeman: https://github.com/collegeman
* @author Joey Blake: https://github.com/joeyblake
*
* Rules:
* - show a list of 10 posts
* - published any time
@joeyblake
joeyblake / gist:7993402
Created December 16, 2013 20:04
SharePress facebook cache bypass filter
add_filter('sp_auto_flush_fb', '__return_false');
@joeyblake
joeyblake / Sample multiple 301 redirects in Ghost
Created January 30, 2014 04:31
Multiple 301 redirects in Ghost
server.get('/*', function(req, res, next) {
var fullURL = req.protocol + "://" + req.get('host') + req.url;
//your 301 redirects
var redirects_301 = {
'http://thinkingandmaking.com/working/92/72-questions-to-ask-on-your-first-day': '/view/72-questions-to-ask-on-your-first-day',
'http://thinkingandmaking.com/working/92/someother': '/view/someother'
}
//check and see if there is a redirect, if so, redirect to it!
if (redirects_301[fullURL]) {
res.redirect(301, redirects_301[fullURL]);
/**
* add this to the functions.php file in your theme to disable fb comments open graph metadata
*/
add_filter('fbc_og_tags', '__return_false');
/**
* If you cannot clean up your open graph meta tags, adding this filter to the functions.php file in your theme will keep
* SharePress from verifying the open graph data.
* Caution: Bad use of open graph meta tags could possibly cause unexpected results in shared images and titles on facebook.
*/
add_filter('sp_auto_flush_fb', '__return_false');
@joeyblake
joeyblake / gist:9474346
Created March 10, 2014 21:08
responsive facebook comments
.fb-comments, .fb-comments iframe[style] {
width: 100% !important;
}