Skip to content

Instantly share code, notes, and snippets.

View jeremyboggs's full-sized avatar

Jeremy Boggs jeremyboggs

View GitHub Profile
<?php
function sanitize_string($string) {
$string = strtolower($string);
// Gets rid of spaces
$sanitized = preg_replace('/\s/', '', $string);
// Gets rid of non-alphanumerics
$sanitized = preg_replace( '/[^A-Za-z0-9_]/', '', $string );
@jeremyboggs
jeremyboggs / people_post_type.php
Created May 29, 2012 19:06
Custom post type for People in WP. Includes dropdown of existing users to associate to the person post.
<?php
/**
* Custom Post Type for People
*/
function people_register_post_types() {
register_post_type( 'people',
array(
'labels' => array(
'name' => __( 'People' ),
<?php
function my_custom_coins_title($coinsTitle)
{
global $post;
$affiliation = get_post_meta($post->ID, 'affiliation', true);
$issue = get_post_meta($post->ID, 'issue', true);
$volume = get_post_meta($post->ID, 'volume', true);
$pub_date = get_post_meta($post->ID, 'pub_date', true);
<?php
if($itemTypeName = Zend_Controller_Front::getInstance()->getRequest()->getParam('type')) {
$itemTypeName = get_db()->getTable('ItemType')->findByName($itemTypeName)->name;
$title = 'Browse '. $itemTypeName . 's';
} else {
$title = 'Browse Items';
}
head(array('title'=>$title,'bodyid'=>'items','bodyclass' => 'browse'));
<?php
/**
* Define the ACL
*/
public function defineAcl($acl)
{
if (version_compare(OMEKA_VERSION, '2.0-dev', '>=')) {
$acl->addResource('Neatline_Exhibits');
<?php
add_plugin_hook('define_acl', 'neatlinews_define_acl');
function neatlinews_define_acl($acl)
{
$resourceList = array(
'Neatline_Index' => array(
'add',
'browse',
<?php
if ($itemImages = get_files(array('item_id' => item('id'), 'has_derivative_image' => 1))) {
echo display_files($itemImages, array('imageSize' => 'fullsize'));
}
?>
@jeremyboggs
jeremyboggs / multiple_creators.php
Created July 31, 2012 18:10
Function to filter item_citation to account for multiple creators.
<?php
/**
* Function to filter item_citation to account for multiple creators.
*/
function item_citation_multiple_creators($cite, $item) {
$cite = '';
if ($creators = item('Dublin Core', 'Creator', array('all' => true), $item)) {
@jeremyboggs
jeremyboggs / exhibit_item_title_switch.php
Created August 14, 2012 23:37
Replace the title of all items in Omeka's Exhibit Builder plugin with a different field.
<?php
/**
* Replace the title of all items in Exhibit Builder with a different field.
*
* Add this to a new plugin, change the field to whatever field you want, and
* activate the plugin.
*/
function exhibit_item_title_switch($title, $item) {
@jeremyboggs
jeremyboggs / findNeatline.php
Created August 21, 2012 13:57
findNeatline method to find a Neatline record by slug or ID
<?php
/**
* Finds a Neatline record by slug or ID.
*
* Checks for existence of 'slug' in URL, then tries to find a Neatline
* record with that slug. If there is no 'slug' parameter, it falls back
* to Omeka_Controller_Action::findById()
*
* @throws Omeka_Controller_Exception_404