'Left',
'before_widget' => '',
'after_widget' => '',
'before_title' => '
',
));
register_sidebar(array(
'name' => 'Center',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
));
register_sidebar(array(
'name' => 'Right',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
));
}
register_sidebar_widget('DePo Square About', 'depo_square_about_widget');
function depo_square_about_widget() { ?>
ID) . "'>About"; } else { ?>
About
have_posts()) : $depo_status_query->the_post(); ?>
Status
Setup your post type categories to have your latest status message appear here.
'', 'after_title' => ' ', 'title' => 'Flickr');
$flickr = new Widget_DePoFlickr;
@$flickr->widget($args);
}
}
$depo_post_types = array(
'post' =>
array(
'id' => 'type-post',
'proper_name' => 'Articles'
),
'status' =>
array(
'id' => 'type-status',
'proper_name' => 'Statuses'
),
'quote' =>
array(
'id' => 'type-quote',
'proper_name' => 'Quotes'
),
'links' =>
array(
'id' => 'type-link',
'proper_name' => 'Links'
),
'photo' =>
array(
'id' => 'type-photo',
'proper_name' => 'Photos'
)
);
function depo_post_category_html () {
$type = depo_post_type();
$type = $type['id'];
echo (!$type or $type == 'type-post') ?
" "
:
" ";
}
function depo_post_type() {
global $depo_post_types;
$custom = false;
foreach( $depo_post_types as $key => $option ) {
if( in_category(get_option( $option['id'] )) ) {
$custom = $option;
}
}
if(!$custom)
return $depo_post_types['post'];
return $custom;
}
function depo_post_category () {
$type = depo_post_type();
$type = $type['id'];
return (!$type or $type == 'type-post') ?
"type-post"
:
$type;
}
// type-photo functions
function replace_empty_tag($m) {
$no_replace = array('embed'); // expand as required
if ( in_array( strtolower($m[1]), $no_replace ) )
return $m[0]; // return the original untouched
return '';
}
// remove image tag from post_content for display
function image_above($entry) {
// don't scrape the image for the feed
if (is_feed()) { return $entry; }
$entry = str_replace('[/wp_caption]','', $entry);
$entry = str_replace('[/caption]','', $entry);
//remove image tag
$image = preg_replace('/ ]*src=(\"|\').+?(\1)[^>]*\/*>/','', $entry);
//remove any empty tags left by the scrape.
$entry = str_replace('
', '', $entry);
$entry = preg_replace_callback( '|<([a-z]+)[^>]*>\s*\1>|i', 'replace_empty_tag', $entry );
$entry = preg_replace_callback( '|<([a-z]+)[^>]*>\s*\1>|i', 'replace_empty_tag', $entry );
$entry = preg_replace_callback( '|<([a-z]+)[^>]*>\s*\1>|i', 'replace_empty_tag', $entry );
return $image.$entry;
}
//admin interface
if( is_admin() ) {
add_action('admin_menu', 'deposquare_add_page');
function deposquare_add_page() {
add_theme_page(__('DePo Square Theme Options'), __('Current Theme Options'), 'administrator', 'depo-square', 'deposquare_do_page');
}
function deposquare_do_page() {
global $depo_post_types;
if( esc_attr( $_POST['action'] ) == 'update' ) {
foreach( $depo_post_types as $key => $option ) {
if( esc_attr( $_POST[ $option['id'] ] ) ) update_option( $option['id'], esc_attr( $_POST[ $option['id'] ] ) );
}
}
foreach( $depo_post_types as $key => $option ) {
register_setting( 'deposquareops', $option['id'], 'intval' );
}
?>
'depo_widget_flickr', 'description' => __( "For DePo Square: Display your flickr photos.") );
$this->WP_Widget('depo-square-flickr', __('DePo Square Flickr'), $widget_ops);
}
function widget( $args, $instance ) {
global $current_blog;
require_once(ABSPATH . WPINC . '/rss.php');
extract( $args );
$flickr_rss_url = esc_url($instance['flickr_rss_url']);
if ( empty($flickr_rss_url) ) $flickr_rss_url = __('http://feeds.feedburner.com/flickr_interestingness');
if( empty($title) ) $title = apply_filters('widget_title', $instance['title']);
if ( empty($title) ) $title = __( 'Flickr' );
if ( empty($items) || $items < 1 || $items > 10 ) $items = 8;
if( !$photos = @wp_cache_get('widget-depo-square-flickr') ) {
$flickr_photos = fetch_rss_summary( $flickr_rss_url, array( 'link', 'title', 'media:thumbnail', 'description' ) );
if( is_array( $flickr_photos->items ) ) {
$photos = '';
$items = array_slice( $flickr_photos->items, 0, $items );
while( list( $key, $photo ) = each( $items ) ) {
$href = wp_specialchars($photo['link'], true);
$itemtitle = wp_specialchars($photo['title'], true);
if ( isset( $photo['media:thumbnail'] ) ) {
$src = str_replace( "_s.jpg", "_t.jpg", wp_specialchars($photo['media:thumbnail']['url'], true) );
} else { // Sometimes the image url is in the description
$src = preg_match( '/src="(.*?)"/i', $photo['description'], $p );
$src = $p[1];
$src = str_replace( '_m.jpg', '_t.jpg', $src );
$src = wp_specialchars( $src, true );
}
if(empty($src)) $src = $photo['enclosure'];
$photos .= " ";
}
$flickr_home = wp_specialchars( $flickr_photos->channel[ 'link' ], true );
$flickr_more_title = wp_specialchars( $flickr_photos->channel[ 'title' ], true );
@wp_cache_add( 'widget-depo-square-flickr', $photos, 'widget', $expire );
}
}
echo $before_title.''.$title.' '.$after_title;
echo '';
if(function_exists('stats_extra') ) stats_extra( 'widget', 'depo-square-flickr' );
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['flickr_rss_url'] = strip_tags(stripslashes($new_instance['flickr_rss_url']));
$instance['title'] = strip_tags(stripslashes($new_instance['title']));
wp_cache_delete( 'widget-depo-square-flickr' , 'widget' );
return $instance;
}
function form( $instance ) {
//Defaults
$instance = wp_parse_args( (array) $instance, array('flickr_rss_url' => '', 'title' => '') );
$flickr_rss_url = esc_attr($instance['flickr_rss_url']);
$title = esc_attr($instance['title']);
echo '' . __('Title:') . '
' . __('RSS URL:') . ' *
* Your RSS feed can be found on your Flickr homepage. Scroll down to the bottom of the page until you see the Feed link and copy that into the box above.
Leave the Flickr RSS URL blank to display interesting Flickr photos.
';
}
}