Skip to content

Instantly share code, notes, and snippets.

@murdaugh
murdaugh / keybase.md
Created January 13, 2015 14:00
keybase.md

Keybase proof

I hereby claim:

  • I am murdaugh on github.
  • I am murdaugh (https://keybase.io/murdaugh) on keybase.
  • I have a public key whose fingerprint is BC4A 3992 7AD1 C06E C767 80BE 28B9 5F95 8B4F C627

To claim this, I am signing this object:

@murdaugh
murdaugh / copy post to blog function
Created October 3, 2013 20:11
Copies a post (as well as its associated meta data) from one wordpress blog to another on the same network.
<?php
function copy_post_to_blog($post_id, $target_blog_id) {
$post = get_post($post_id, ARRAY_A); // get the original post
$meta = get_post_meta($post_id);
$post['ID'] = ''; // empty id field, to tell wordpress that this will be a new post
switch_to_blog($target_blog_id); // switch to target blog
$inserted_post_id = wp_insert_post($post); // insert the post
foreach($meta as $key=>$value) {
update_post_meta($inserted_post_id,$key,$value[0]);
}
<?php
function my_strftime($format,$time=null) {
global $my_locale; //this is set in the header as either en_US or es_ES
if($time == null) $time = time(); //if the time isn't passed in, then use the current timestamp
if($my_locale == "en_US") return strftime($format,$time); //If it's american english, just format the time as requested
else { //in my case, the only other option is es_ES, but this could be changed for whatever purposes you have
global $es_locale_string;
// we only care about day names and abbreviations and
array (
"weekday"=>array("Domingo","Lunes","Martes","Mi&eacute;rcoles","Jueves","Viernes","S&aacute;bado"),
"weekday_initial"=>array("D","L","M","M","J","V","S"),
"weekday_abbrev"=>array("Dom","Lun","Mar","Mie","Jue","Vie","Sab"),
"month"=>array("enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"),
"month_abbrev"=>array("ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic")
);
@murdaugh
murdaugh / gist:2714140
Created May 16, 2012 21:37
Flickr JSON PHP
<?php
echo flickr_feed('http://api.flickr.com/services/feeds/photos_public.gne?id=12345678@N06&format=json&nojsoncallback=1');
function flickr_feed($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);