Skip to content

Instantly share code, notes, and snippets.

View alanedwardes's full-sized avatar
👋

Alan Edwardes alanedwardes

👋
View GitHub Profile
@alanedwardes
alanedwardes / gist:1396447
Created November 26, 2011 22:54
Evil bit of SQL to get the most recent posts from WordPress with media, the link to the media and the post ID.
SELECT posts.post_title, posts.ID post_id, media.ID media_id
FROM $wpdb->posts media
JOIN $wpdb->posts posts
ON posts.post_content LIKE CONCAT('%', media.guid, '%')
WHERE media.post_type = 'attachment'
AND posts.post_type = 'post'
AND posts.post_status = 'publish'
GROUP BY posts.ID
ORDER BY media.post_date DESC
LIMIT 0, 9
@alanedwardes
alanedwardes / mint.php
Created October 9, 2011 17:42
WordPress plugin to add mint to the blog's header (if the user isn't logged in) and to add a "Statistics" menu option with Mint in an iframe.
<?php
/*
Plugin Name: WordPress Mint Intergration
Description: Adds mint to the site's header (if the user isn't logged in), adds a "Statistics" menu option with Mint in an iframe.
Author: Alan Edwardes
Author URI: http://alan.edward.es/
Version: 1.0
*/
function add_mint_javascript(){
// By Alan Edwardes - http://alanedwardes.com/contact
// Licensed under The GNU General Public License (GPL)
// -------------------------------------------------------------
// A simple events wrapper function for adding events that works
// cross browser, and allows you to use the first parameter of
// the callback function as a reference to the object that the
// event was fired from, which replaces IE's lack of support
// for the "this" variable.
//
// Ex. Usage: