]*).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>(.*?)<\/a>/i";
$replacement = '$7 ';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
/*******************************
WORDPRESS
********************************/
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 90, 90, true);
add_image_size('col2img',600,350,true);
add_image_size('col1img',300,200,true);
add_theme_support( 'automatic-feed-links' );
if ( ! isset( $content_width ) )
$content_width = 1000;
/*******************************
MENU SUPPORT
********************************/
function register_my_menus() {
register_nav_menus(
array('header-menu' => __( 'Header Menu' ) )
);
}
add_action( 'init', 'register_my_menus' );
/*******************************
SIDEBAR SUPPORT
********************************/
if ( function_exists('register_sidebar') )
register_sidebar(array('name'=>'Main Sidebar',
'before_widget' => '',
'before_title' => '
',
));
if ( function_exists('register_sidebar') )
register_sidebar(array('name'=>'Footer Widgets',
'before_widget' => '',
'before_title' => '',
));
/*******************************
HTML5 COMMENTS
********************************/
function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
id="comment-"> ' ); ?>
comment_approved == '0') : ?>
' (string). The html or text
* to add before the pagination links.
* 'after' - Default is '' (string). The html or text to add after the
* pagination links.
* 'title' - Default is '__('Pages:')' (string). The text to display before the
* pagination links.
* 'next_page' - Default is '__('»')' (string). The text to use for the
* next page link.
* 'previous_page' - Default is '__('«')' (string). The text to use for the
* previous page link.
* 'echo' - Default is 1 (int). To return the code instead of echo'ing, set this
* to 0 (zero).
*
* @author Eric Martin
* @copyright Copyright (c) 2009, Eric Martin
* @version 1.0
*
* @param array|string $args Optional. Override default arguments.
* @return string HTML content, if not displaying.
*/
function emm_paginate($args = null) {
$defaults = array(
'page' => null, 'pages' => null,
'range' => 3, 'gap' => 3, 'anchor' => 1,
'before' => '', 'after' => '
',
'title' => __(''),
'nextpage' => __('»'), 'previouspage' => __('«'),
'echo' => 1
);
$r = wp_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
if (!$page && !$pages) {
global $wp_query;
$page = get_query_var('paged');
$page = !empty($page) ? intval($page) : 1;
$posts_per_page = intval(get_query_var('posts_per_page'));
$pages = intval(ceil($wp_query->found_posts / $posts_per_page));
}
$output = "";
if ($pages > 1) {
$output .= "$before$title ";
$ellipsis = "... ";
if ($page > 1 && !empty($previouspage)) {
$output .= "$previouspage ";
}
$min_links = $range * 2 + 1;
$block_min = min($page - $range, $pages - $min_links);
$block_high = max($page + $range, $min_links);
$left_gap = (($block_min - $anchor - $gap) > 0) ? true : false;
$right_gap = (($block_high + $anchor + $gap) < $pages) ? true : false;
if ($left_gap && !$right_gap) {
$output .= sprintf('%s%s%s',
emm_paginate_loop(1, $anchor),
$ellipsis,
emm_paginate_loop($block_min, $pages, $page)
);
}
else if ($left_gap && $right_gap) {
$output .= sprintf('%s%s%s%s%s',
emm_paginate_loop(1, $anchor),
$ellipsis,
emm_paginate_loop($block_min, $block_high, $page),
$ellipsis,
emm_paginate_loop(($pages - $anchor + 1), $pages)
);
}
else if ($right_gap && !$left_gap) {
$output .= sprintf('%s%s%s',
emm_paginate_loop(1, $block_high, $page),
$ellipsis,
emm_paginate_loop(($pages - $anchor + 1), $pages)
);
}
else {
$output .= emm_paginate_loop(1, $pages, $page);
}
if ($page < $pages && !empty($nextpage)) {
$output .= "$nextpage ";
}
$output .= $after;
}
if ($echo) {
echo $output;
}
return $output;
}
/**
* Helper function for pagination which builds the page links.
*
* @access private
*
* @author Eric Martin
* @copyright Copyright (c) 2009, Eric Martin
* @version 1.0
*
* @param int $start The first link page.
* @param int $max The last link page.
* @return int $page Optional, default is 0. The current page.
*/
function emm_paginate_loop($start, $max, $page = 0) {
$output = "";
for ($i = $start; $i <= $max; $i++) {
$output .= ($page === intval($i))
? "$i "
: "$i ";
}
return $output;
}
function post_is_in_descendant_category( $cats, $_post = null )
{
foreach ( (array) $cats as $cat ) {
// get_term_children() accepts integer ID only
$descendants = get_term_children( (int) $cat, 'category');
if ( $descendants && in_category( $descendants, $_post ) )
return true;
}
return false;
}
/*******************************
CSS VERSIONING
********************************/
// Custom Functions for CSS/Javascript Versioning
$GLOBALS["TEMPLATE_URL"] = get_bloginfo('template_url')."/";
$GLOBALS["TEMPLATE_RELATIVE_URL"] = wp_make_link_relative($GLOBALS["TEMPLATE_URL"]);
// Add ?v=[last modified time] to style sheets
function versioned_stylesheet($relative_url, $add_attributes=""){
echo ' '."\n";
}
// Add ?v=[last modified time] to javascripts
function versioned_javascript($relative_url, $add_attributes=""){
echo ''."\n";
}
// Add ?v=[last modified time] to a file url
function versioned_resource($relative_url){
$file = $_SERVER["DOCUMENT_ROOT"].$relative_url;
$file_version = "";
if(file_exists($file)) {
$file_version = "?v=".filemtime($file);
}
return $relative_url.$file_version;
}
/*******************************
THE WORDPRESS GALLERY SUCKS
********************************/
add_filter( 'post_gallery', 'amp_gallery', 10, 2 );
function amp_gallery( $output, $attr ) {
global $post;
static $amp_gallery_instance = 0;
$amp_gallery_instance++;
if ( is_feed() )
return $output;
if ( isset( $attr['orderby'] ) ) {
$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
if ( !$attr['orderby'] )
unset( $attr['orderby'] );
}
$defaults = array(
'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => $post->ID,
'link' => '',
'itemtag' => 'div',
'captiontag' => 'div',
'size' => 'thumbnail',
'include' => '',
'exclude' => '',
'numberposts' => -1,
'offset' => ''
);
$defaults = apply_filters( 'amp_gallery_defaults', $defaults );
$attr = shortcode_atts( $defaults, $attr );
extract( $attr );
$id = intval( $id );
$children = array(
'post_parent' => $id,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => $order,
'orderby' => $orderby,
'exclude' => $exclude,
'include' => $include,
'numberposts' => $numberposts,
'offset' => $offset,
);
$attachments = get_children( $children );
if ( empty( $attachments ) )
return '';
$itemtag = tag_escape( $itemtag );
$captiontag = tag_escape( $captiontag );
$i = 0;
$attachment_count = count( $attachments );
$output = "\n\t\t\t";
foreach ( $attachments as $id => $attachment ) {
$output .= "\n\t\t\t\t\t<{$itemtag} class='gallery-item'>";
$image = ( ( isset( $attr['link'] ) && 'file' == $attr['link'] ) ? wp_get_attachment_link( $id, $size, false, false ) : wp_get_attachment_link( $id, $size, true, false ) );
$output .= apply_filters( 'amp_gallery_image', $image, $id, $attr, $amp_gallery_instance );
$caption = apply_filters( 'amp_gallery_caption', wptexturize( esc_html( $attachment->post_excerpt ) ), $id, $attr, $amp_gallery_instance );
if ( !empty( $caption ) )
$output .= "\n\t\t\t\t\t\t<{$captiontag} class='gallery-caption'>{$caption}{$captiontag}>";
$output .= "\n\t\t\t\t\t{$itemtag}>";
}
$output .= "\n\t\t\t
\n";
return $output;
}
/*******************************
THEME OPTIONS PAGE
********************************/
add_action('admin_menu', 'amphitheatre_theme_page');
function amphitheatre_theme_page ()
{
if ( count($_POST) > 0 && isset($_POST['amphitheatre_settings']) )
{
$options = array ('logo_img','keywords','description','analytics','copyright');
foreach ( $options as $opt )
{
delete_option ( 'amphitheatre_'.$opt, $_POST[$opt] );
add_option ( 'amphitheatre_'.$opt, $_POST[$opt] );
}
}
add_menu_page(__('Amphitheatre Options'), __('Amphitheatre Options'), 'edit_themes', basename(__FILE__), 'amphitheatre_settings');
add_submenu_page(__('Amphitheatre Options'), __('Amphitheatre Options'), 'edit_themes', basename(__FILE__), 'amphitheatre_settings');
}
function amphitheatre_settings()
{?>
Amphitheatre Options
Amphitheatre by Mogki