' . $commenter . '';
}
// Sandbox gallery short code; styles used in style.css file
function sandbox_gallery($attr) {
global $post;
// Sets our defaults for the Sandbox gallery short code
extract( shortcode_atts(
array(
'orderby' => 'menu_order ASC, ID ASC',
'id' => $post->ID,
'itemtag' => 'dl',
'icontag' => 'dt',
'captiontag' => 'dd',
'columns' => 3,
'size' => 'thumbnail',
),
$attr ) );
$id = intval($id);
$orderby = addslashes($orderby);
$attachments = get_children("post_parent=$id&post_type=attachment&post_mime_type=image&orderby=\"{$orderby}\"");
// If we have nothing, show nothing
if ( empty($attachments) )
return '';
// Shows simple image links when viewed in a feed
if ( is_feed() ) {
$output = "\n";
foreach ( $attachments as $id => $attachment )
$output .= wp_get_attachment_link( $id, $size, true ) . "\n";
return $output;
}
$listtag = tag_escape($listtag);
$itemtag = tag_escape($itemtag);
$captiontag = tag_escape($captiontag);
$columns = intval($columns);
// Divides number of columns for even widths
$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
// Let's begin our gallery
$output = apply_filters( "gallery_style", "" );
// We're using pretty much the same code from ../wp-includes/media.php
foreach ( $attachments as $id => $attachment ) {
$link = wp_get_attachment_link( $id, $size, true );
// This is our 'wrapper' for each gallery item
$output .= "<{$itemtag} class='gallery-item' style='width:{$itemwidth}%;'>";
// And now we have the actual image link
$output .= "<{$icontag} class='gallery-icon'>$link{$icontag}>";
// Next, show the image caption if present
if ( $captiontag && trim($attachment->post_excerpt) ) {
$output .= "<{$captiontag} class='gallery-caption'>{$attachment->post_excerpt}{$captiontag}>";
}
// Close the gallery item 'wrapper'
$output .= "{$itemtag}>";
// Start a new gallery set for our 'columns'
if ( $columns > 0 && ++$i % $columns == 0 ) {
$gallery_count = 2;
$output .= "\n
\n\n";
$gallery_count++;
}
}
// Ends our gallery
$output .= "
\n";
// And spits out the chewed up code
return $output;
}
// Widget: Pages; to match the theme style and replace Widget plugin default
function widget_sandbox_pages( $args ) {
extract( $args );
$options = get_option( 'widget_pages' );
$title = empty( $options['title'] ) ? __( 'Pages' ) : $options['title'];
$sortby = empty( $options['sortby'] ) ? 'menu_order' : $options['sortby'];
$exclude = empty( $options['exclude'] ) ? '' : $options['exclude'];
if ( $sortby == 'menu_order' ) {
$sortby = 'menu_order, post_title';
}
$out = wp_list_pages( array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude) );
if ( !empty( $out ) ) {
?>
"\n\t\t\t" . '',
'after_widget' => "\n\t\t\t\n",
'before_title' => "\n\t\t\t\t". '\n"
);
// Table for how many? One? This way, please.
register_sidebars( 1, $p );
// Finished intializing Widgets plugin, now let's load the Sandbox default widgets; first, Sandbox search widget
$widget_ops = array(
'classname' => 'widget_pages',
'description' => __( "Your blog's WordPress Pages (Autumn Forest)", "sandbox" )
);
wp_register_sidebar_widget( 'pages', __( 'Pages', 'sandbox' ), 'widget_sandbox_pages', $widget_ops );
unregister_widget_control('pages');
wp_register_widget_control( 'pages', __( 'Pages', 'sandbox' ), 'widget_sandbox_pages_control' );
$widget_ops = array(
'classname' => 'widget_search',
'description' => __( "A search form for your blog (Autumn Forest)", "sandbox" )
);
wp_register_sidebar_widget( 'search', __( 'Search', 'sandbox' ), 'widget_sandbox_search', $widget_ops );
$widget_ops = array(
'classname' => 'widget_recent_entries',
'description' => __( "The most recent posts on your blog (Autumn Forest)", "sandbox" )
);
wp_register_sidebar_widget( 'recent-posts', __( 'Recent Posts', 'sandbox' ), 'widget_sandbox_recent_entries', $widget_ops );
unregister_widget_control('recent-posts');
wp_register_widget_control( 'recent-posts', __( 'Recent Posts', 'sandbox' ), 'widget_sandbox_recent_entries_control' );
$widget_ops = array(
'classname' => 'widget_rss_links',
'description' => __( "RSS links for posts (Autumn Forest)", "sandbox" )
);
wp_register_sidebar_widget( 'rss_links', __( 'RSS Links', 'sandbox' ), 'widget_sandbox_rsslinks', $widget_ops );
wp_register_widget_control( 'rss_links', __( 'RSS Links', 'sandbox' ), 'widget_sandbox_rsslinks_control' );
$widget_ops = array(
'classname' => 'widget_tag_cloud',
'description' => __( "Your most used tags in cloud format (Autumn Forest)", "sandbox" )
);
wp_register_sidebar_widget( 'tag_cloud', __( 'Tag Cloud', 'sandbox' ), 'widget_sandbox_tag_cloud', $widget_ops );
unregister_widget_control('tag_cloud');
wp_register_widget_control( 'tag_cloud', __( 'Tag Cloud', 'sandbox' ), 'widget_sandbox_tag_cloud_control' );
}
// Translate, if applicable
load_theme_textdomain('sandbox');
// Runs our code at the end to check that everything needed has loaded
add_action( 'init', 'sandbox_widgets_init' );
// Add Sandbox function to gallery short code
add_shortcode( 'gallery', 'sandbox_gallery' );
// Adds filters so that things run smoothly
add_filter( 'archive_meta', 'wptexturize' );
add_filter( 'archive_meta', 'convert_smilies' );
add_filter( 'archive_meta', 'convert_chars' );
add_filter( 'archive_meta', 'wpautop' );
// Remember: the Sandbox is for play.
?>