This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom function to retrieve any number of random featured items. | |
* | |
* @param int $num The number of random featured items to return | |
* @param boolean $withImage Whether to return items with derivative images. True by default. | |
* @return array An array of Omeka Item objects. | |
*/ | |
function custom_get_random_featured_items($num = '10', $withImage = true) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Returns a link to the first section in an exhibit. | |
* | |
* @param Exhibit $exhibit|null If null, it uses the current exhibit | |
* @param string $text|null If null, the link will use the title of the section. | |
* @param array $props An array of properties for the link. | |
*/ | |
function link_to_first_exhibit_section($exhibit = null, $text = null, $props = array()) { | |
if (!$exhibit) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Converts any URLs in a given string to links. | |
* | |
* @param string $str The string to be searched for URLs to convert to links. | |
* @return string | |
*/ | |
function url_to_link($str) | |
{ | |
$pattern = "@\b(https?://)?(([0-9a-zA-Z_!~*'().&=+$%-]+:)?[0-9a-zA-Z_!~*'().&=+$%-]+\@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+\.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\.[a-zA-Z]{2,6})(:[0-9]{1,4})?((/[0-9a-zA-Z_!~*'().;?:\@&=+$,%#-]+)*/?)@"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. ?> |
OlderNewer