Skip to content

Instantly share code, notes, and snippets.

View jeremyboggs's full-sized avatar

Jeremy Boggs jeremyboggs

View GitHub Profile
<?php
/**
* Removes inline width and height attributes for images. Thanks to
* @boonebgorges and @wayne_graham for help with this!
*/
function clioweb_remove_inline_sizes($html) {
$pattern = '/(\sheight|\swidth)="(.*?)"/';
$html = preg_replace($pattern, '', $html);
return $html;
}
@jeremyboggs
jeremyboggs / Custom Random Featured Items helper.php
Created January 26, 2011 19:35
A helper function for Omeka to retrieve any number of random featured items. Include this function in your Omeka theme's custom.php file, and use wherever you'd like to get some random featur
@jeremyboggs
jeremyboggs / wikicite.php
Created February 11, 2011 00:09
Use WikiCite for Omeka plugin instead! http://github.com/clioweb/WikiCiteOmeka Generates Wikipedia citation code for an Omeka Item, and appends to the items/show page.
<?php
/*
I created an Omeka plugin, WikiCite for Omeka, based on this code:
http://github.com/clioweb/WikiCiteOmeka
*/
/**
* Generates Wikipedia citation code for an Omeka Item, and appends to the items/show page.
* Based on Cite_web template at http://en.wikipedia.org/wiki/Template:Cite_web, and
@jeremyboggs
jeremyboggs / wordpress-rewrite-rules.php
Created February 24, 2011 23:13
Some methods I generally use to create my own rewrite rules for WordPress. Taken from WordHub project.
<?php
/**
* Some basics for creating your own rewrite rules in WordPress. Taken from
* my WordHub plugin.
*/
class Whatever {
function init() {
add_action( 'rewrite_rules_array', array( $this, 'rewrite_rules_array') );
add_filter( 'query_vars', array( $this, 'query_vars' ) );
@jeremyboggs
jeremyboggs / link_to_first_exhibit_section
Created March 1, 2011 16:03
Returns a link to the first section in an Omeka exhibit.
@jeremyboggs
jeremyboggs / WpNetworkActivation.php
Created March 7, 2011 03:41
Logic to run whatever activation scripts a WP plugin needs if activated network-wide.
<?php
function activation() {
global $wpdb;
// If we've got a multisite instance of WP
if (function_exists('is_multisite') && is_multisite()) {
// check if it is a network activation
if (isset($_GET['networkwide']) && ($_GET['networkwide'] == 1)) {
@jeremyboggs
jeremyboggs / url_to_link.php
Created March 12, 2011 13:54
Converts a URL string to a link and returns the link.
@jeremyboggs
jeremyboggs / custom-post-type-flush-rewrite-rules.php
Created March 15, 2011 22:00
Pseudo-elegant way to flush rewrite rules after creating a custom post type.
<?php
/**
* Example for writing a WP plugin that adds a custom post type and flushes
* rewrite rules only once on initialization.
*/
/**
* On activation, we'll set an option called 'my_plugin_name_flush' to true,
* so our plugin knows, on initialization, to flush the rewrite rules.
*/
@jeremyboggs
jeremyboggs / custom-item-form-tab-order.php
Created March 23, 2011 15:13
Function to move the tab of a specific element set to the top of the items form tab list.
<?php
/**
* Prepends the item form tabs with a specific element set.
*
* @param array The item form tabs. These will get filtered.
* @return array A modified array of item form tabs.
*/
function custom_item_form_tab_order($tabs) {
// The name of our element set. What the link in the tab says.
@jeremyboggs
jeremyboggs / wp-loop-checks-first-post.php
Created March 30, 2011 02:46
Adds a counter to check for the first post in a WP loop.
<?php $count = 0; ?>
<?php if( have_posts() ) : while( have_posts() ) : the_post(); ++$count; ?>
<div class="post">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<?php if (($count == '1') && (!is_paged())): // If it's the first post on the first page. ?>
<?php if ( has_post_thumbnail() ) the_post_thumbnail(); ?>
<?php the_excerpt(); ?>
<?php else: // If it's any other post on any other page. ?>