Skip to content

Instantly share code, notes, and snippets.

murdaugh

Block or report user

Report or block murdaugh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View 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 Oct 3, 2013
Copies a post (as well as its associated meta data) from one wordpress blog to another on the same network.
View copy post to blog function
<?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]);
}
View custom locale function
<?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
View spanish strings
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
Flickr JSON PHP
View gist:2714140
<?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);
You can’t perform that action at this time.