Skip to content

Instantly share code, notes, and snippets.

@raamdev
raamdev / flickr-random-photo.php
Created October 6, 2012 05:49
Load a Flickr photo set and then display a random photo from that set
<?php
/**
* Raam Dev - http://raamdev.com/
*
* This code loads a Flickr Photo Set and then picks a random photo from that set
* After configuring your settings and loading the PHP, you can display the random photo as follows:
* <a href="<?php echo $flickr_img_url_large; ?>" title="<?php echo $flickr_photo_description; ?>">
* <img title="<?php echo $flickr_photo_description; ?>" border="0" src="<?php echo $flickr_img_url; ?>" />
* </a>
*
@raamdev
raamdev / postie-functions.php
Created March 21, 2013 19:51
Adds support for Post Formats to the WordPress Postie plugin. You can now specify a post format in the email subject like this: "Aside :: My Aside-formatted post". My changes to postie-functions.php can be found on lines L232, L305, L402, L803, and L2421.
<?php
/*
$Id: postie-functions.php 683869 2013-03-18 21:39:57Z WayneAllen $
*/
//to turn on debug output add the following line to wp-config.php
//define('POSTIE_DEBUG', true);
if (!function_exists('mb_str_replace')) {
<?php
/* Add a checkbox to the featured image metabox */
add_filter( 'admin_post_thumbnail_html', 'theme_featured_image_meta');
function theme_featured_image_meta( $content ) {
global $post;
// Text for checkbox
$text = __( "Don't display image on post.", 'textdomain' );
@raamdev
raamdev / gist:8550578
Last active January 4, 2016 01:49
WordPress Shortcode for outputting a list of recent posts. Includes many options.
<?php
if ( ! function_exists( 'independent_publisher_recent_posts_shortcode' ) ) :
/**
* Returns recent posts for given category and excludes given post formats
*
* Example usage: [independent_publisher_recent_posts count="10" category="Technology" exclude_formats="aside,gallery,link" more_text="« Full Archives"]
*/
function independent_publisher_recent_posts_shortcode( $atts /*$number_posts = '10', $category = '', $exclude_formats = array()*/ ) {
$formats_to_exclude = '';
@raamdev
raamdev / add_filter_example.php
Created January 23, 2014 16:31
add_filter() example
<?php
add_filter( 'stcr_confirmation_email_message', 'modify_email_message', 10, 3 );
function modify_email_message( $message, $_post_ID, $email ) {
$message = $message . "Adding something to the end of my email confirmation message.";
return $message;
}
<?php
/*
Plugin Name: Subscribe to Comments Reloaded
Version: 140125
Stable tag: 140125
Requires at least: 2.9.2
Tested up to: 3.8
Plugin URI: http://wordpress.org/extend/plugins/subscribe-to-comments-reloaded/
# Download & install marports http://www.macports.org/install.php
$ sudo port selfupdate
$ sudo port install nginx
$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.nginx.plist
$ sudo port install php5 +fastcgi fcgi
$ sudo mkdir /opt/local/etc/LaunchDaemons/org.macports.php-fastcgi
$ cd /opt/local/etc/LaunchDaemons/org.macports.php-fastcgi
$ mate org.macports.php-fastcgi.plist # or vim org.macports.php-fastcgi.plist
@raamdev
raamdev / nginx-mamp-macports.txt
Last active February 24, 2023 08:02
These are the steps to get Nginx running alongside MAMP on a Mac.
# These steps will get nginx installed on your Mac for local development and
# testing purposes, to be used alongside MAMP (which already includes Apache).
# The following steps assume that you're running MAMP and that you already
# have php-cgi in /Applications/MAMP/bin/php/php5.4.10/bin/php-cgi.
# The start-nginx and stop-nginx scripts created at the end do not
# start or stop MySQL because it is assumed that you normally run MAMP
# with Apache + MySQL turned on and that you occasionally want to switch
# your web server to Nginx for testing purposes and that you leave MySQL running.
# This process was tested successfully on OS X 10.9.
@raamdev
raamdev / get.dev.sh
Last active November 2, 2015 08:21
Wildcard domains for development (*.dev) made simple, now with MacPorts support. See http://dev.sh for the original script.
#!/bin/sh
set -o errexit
set -e
# Fail fast if we're not on OS X >= 10.6.0.
if [ "$(uname -s)" != "Darwin" ]; then
echo "Sorry, DevDNS requires Mac OS X to run." >&2
exit 1
FileETag none
<IfModule mod_headers.c>
Header unset etag
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType text/plain "access plus 1 week"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"