<?php
include("includes/theme-options.php");
// Uncomment this to test your localization, make sure to enter the right language code.
// function test_localization( $locale ) {
// return "nl_NL";
// }
// add_filter('locale','test_localization');
load_theme_textdomain('themejunkie', TEMPLATEPATH.'/languages/');
// General Widgets
if (function_exists('register_sidebar'))
{
register_sidebar(array(
'name' => 'Sidebar',
'before_widget' => '',
'after_widget' => '<div class="clear"></div></div></div>',
'before_title' => '<div class="widget"><h3>',
'after_title' => '</h3><div class="widgetbox">',
));
register_sidebar(array(
'name' => 'Footer Widget #1',
'before_widget' => '',
'after_widget' => '<div class="clear"></div></div></div>',
'before_title' => '<div class="footerwidget"><h3>',
'after_title' => '</h3><div class="widgetbox">',
));
register_sidebar(array(
'name' => 'Footer Widget #2',
'before_widget' => '',
'after_widget' => '<div class="clear"></div></div></div>',
'before_title' => '<div class="footerwidget"><h3>',
'after_title' => '</h3><div class="widgetbox">',
));
register_sidebar(array(
'name' => 'Footer Widget #3',
'before_widget' => '',
'after_widget' => '<div class="clear"></div></div></div>',
'before_title' => '<div class="footerwidget"><h3>',
'after_title' => '</h3><div class="widgetbox">',
));
register_sidebar(array(
'name' => 'Footer Widget #4',
'before_widget' => '',
'after_widget' => '<div class="clear"></div></div></div>',
'before_title' => '<div class="footerwidget"><h3>',
'after_title' => '</h3><div class="widgetbox">',
));
}
# Content Excerpts
function tj_content_limit($max_char, $more_link_text = '', $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$content = strip_tags($content);
if (strlen($_GET['p']) > 0) {
echo "";
echo $content;
echo "...";
}
else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
$content = substr($content, 0, $espacio);
$content = $content;
echo "";
echo $content;
echo "...";
}
else {
echo "";
echo $content;
}
}
// Turn a category ID to a Name
function cat_id_to_name($id) {
foreach((array)(get_categories()) as $category) {
if ($id == $category->cat_ID) { return $category->cat_name; break; }
}
}
// Get Image Attachments
function tj_get_image($postid=0, $size='full') {
if ($postid<1)
$postid = get_the_ID();
$thumb = get_post_meta($postid, "thumb", TRUE); // Declare the custom field for the image
if ($thumb != null or $thumb != '') {
echo $thumb;
}
elseif ($images = get_children(array(
'post_parent' => $postid,
'post_type' => 'attachment',
'numberposts' => '1',
'post_mime_type' => 'image', )))
foreach($images as $image) {
$thumbnail=wp_get_attachment_image_src($image->ID, $size);
?>
<?php echo $thumbnail[0]; ?>
<?php }
else {
echo get_bloginfo ( 'stylesheet_directory' );
echo '/images/image-pending.gif';
}
}
// Show Post Thumbnails
function tj_show_thumb($width = 100, $height = 100) {
?>
<a href="<?php the_permalink() ?>" rel="bookmark"><img class="thumb" src="<?php bloginfo('template_directory'); ?>/includes/timthumb.php?src=<?php tj_get_image($post->ID, 'full'); ?>&h=<?php echo get_theme_mod($height); ?>&w=<?php echo get_theme_mod($width); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
<?php
}
// Tabber: Get Most Popular Posts
function tj_tabs_popular( $posts = 5, $size = 35 ) {
$popular = new WP_Query('orderby=comment_count&posts_per_page='.$posts);
while ($popular->have_posts()) : $popular->the_post();
?>
<li>
<?php tj_show_thumb($size, $size); ?>
<div class="info">
<a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<span class="meta"><?php comments_popup_link('0 Comment', '1 Comment', '% Comments', 'comments-link', ''); ?></span>
</div> <!--end .info-->
<div class="clear"></div>
</li>
<?php endwhile;
}
function tj_tabs_latest( $posts = 5, $size = 35 ) {
$the_query = new WP_Query('showposts='. $posts .'&orderby=post_date&order=desc');
while ($the_query->have_posts()) : $the_query->the_post();
?>
<li>
<?php if ($size <> 0) ?>
<?php tj_show_thumb($size, $size);?>
<div class="info">
<a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<span class="meta"><?php the_time('F j, Y'); ?></span>
</div> <!--end .info-->
<div class="clear"></div>
</li>
<?php endwhile;
}
// Tabber: Get Recent Comments
function tj_tabs_comments( $posts = 5, $size = 35 ) {
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,
comment_post_ID, comment_author, comment_author_email, comment_date_gmt, comment_approved,
comment_type,comment_author_url,
SUBSTRING(comment_content,1,65) AS com_excerpt
FROM $wpdb->comments
LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
$wpdb->posts.ID)
WHERE comment_approved = '1' AND comment_type = '' AND
post_password = ''
ORDER BY comment_date_gmt DESC LIMIT ".$posts;
$comments = $wpdb->get_results($sql);
foreach ($comments as $comment) {
?>
<li>
<?php echo get_avatar( $comment, $size ); ?>
<a href="<?php echo get_permalink($comment->ID); ?>#comment-<?php echo $comment->comment_ID; ?>" title="<?php _e('on ', 'themejunkie'); ?> <?php echo $comment->post_title; ?>">
<?php echo strip_tags($comment->comment_author); ?>: <?php echo strip_tags($comment->com_excerpt); ?>...
</a>
<div class="clear"></div>
</li>
<?php
}
}
include("setting.php");
?>
Alles anzeigen