<?php
require_once(TEMPLATEPATH . '/panel/theme-styles.php');
require_once(TEMPLATEPATH . '/panel/theme-option.php');
require_once(TEMPLATEPATH . '/includes/theme-widgets.php');
require_once(TEMPLATEPATH . "/includes/theme-js.php");
require_once(TEMPLATEPATH . "/includes/pagenavi.php");
if ( ! isset( $content_width ) ) $content_width = 900;
/** Add theme support for Feed Links. */
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'custom-background');
add_editor_style();
/** enqueue */
if ( is_singular() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );

/* Yazı resim küçültüçü. */

if ( function_exists( 'add_theme_support' ) ) {
	add_theme_support( 'post-thumbnails' );
	
	//default thumbnail size
    add_image_size( 'entry-thumbcat',50, 50, true );
    add_image_size( 'entry-thumb',275, 175, true );
		
};
// Register Menu
function register_my_menus() {
  register_nav_menus(
    array(
      'header-menu' => __("Header Menu", "drk"),
      'page-menu' => __("Page Menu", "drk")
    )
  );
}
add_action( 'init', 'register_my_menus' );

/*-----------------------------------------------------------------------------------*/
/* Show analytics code in footer */
/*-----------------------------------------------------------------------------------*/
function drk_analytics(){
	$output = get_option('drk_google_analytics');
	if ( $output <> "" ) 
		echo stripslashes($output) . "\n";
}
add_action('wp_footer','drk_analytics');

// Register Widgets
function drk_widgets_init() {
    // Home Sidebar
	register_sidebar( array (
		'name' => __( 'Home Sidebar', 'drk' ),
		'id' => 'home-sidebar',
		'description' => __( 'Home Sidebar', 'drk' ),
		'before_widget' => '<div id="%1$s" class="widget clear %2$s">',
		'after_widget' => "</div>",
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );		
	// Page Sidebar
	register_sidebar( array (
		'name' => __( 'Page Sidebar', 'drk' ),
		'id' => 'page-sidebar',
		'description' => __( 'Page Sidebar', 'drk' ),
		'before_widget' => '<div id="%1$s" class="widget clear %2$s">',
		'after_widget' => "</div>",
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );

	// Post Sidebar
	register_sidebar( array (
		'name' => __( 'Post Sidebar', 'drk' ),
		'id' => 'post-sidebar',
		'description' => __( 'Post Sidebar', 'drk' ),
		'before_widget' => '<div id="%1$s" class="widget clear %2$s">',
		'after_widget' => "</div>",
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );
}
add_action( 'init', 'drk_widgets_init' );
/*-----------------------------------------------------------------------------------*/
/*	limit excerpt	
/*-----------------------------------------------------------------------------------*/
function drk_custom_excerpt_length( $length ) {
	return 130;
}
add_filter( 'excerpt_length', 'drk_custom_excerpt_length', 999 );

function drk_excerpt_more( $more ) {
	return '...';
}
add_filter('excerpt_more', 'drk_excerpt_more');
/*-----------------------------------------------------------------------------------*/
/* Breadcrumb	Anasayfa / bla / bla 
/*-----------------------------------------------------------------------------------*/
function drk_breadcrumb() {
  $sep = ' / ';

    if (!is_front_page()) {

        echo '<div class="breadcrumbs">';
        echo '' . __( 'Buradasınız : ' , 'drk' ) . '';
        echo '<a href="';
        echo home_url('');
        echo '">';
        echo '' . __( 'Anasayfa' , 'drk' ) . '';
        echo '</a>' . $sep;

        if (is_category() || is_single() ){
            the_category('title_li=');
        }   elseif (is_archive() || is_single()){
            if ( is_day() ) {
                printf( __( '%s', 'drk' ), get_the_date() );
            } elseif ( is_month() ) {
                printf( __( '%s', 'drk' ), get_the_date( _x( 'F Y', 'aylık arşiv tarih biçimi', 'drk' ) ) );
            } elseif ( is_year() ) {
                printf( __( '%s', 'drk' ), get_the_date( _x( 'Y', 'yıllık arşiv tarih biçimi', 'drk' ) ) );
            } else {
                _e( 'Arşivler', 'drk' );
            }
        }

        if (is_single()) {
            echo $sep;
            the_title();
        }

        if (is_page()) {
            echo the_title();
        }

        if (is_home()){
            global $post;
            $page_for_posts_id = get_option('page_for_posts');
            if ( $page_for_posts_id ) { 
                $post = get_page($page_for_posts_id);
                setup_postdata($post);
                the_title();
                rewind_posts();
            }
        }
        echo '</div>';
    }
}
          
/*-----------------------------------------------------------------------------------*/
# Page Navigation
/*-----------------------------------------------------------------------------------*/
function drk_pagenavi(){
	?>
	<div class="pagination">
		<?php drk_get_pagenavi() ?>
	</div>
	<?php
}
	
// Make theme available for translation
	// Translations can be filed in the /languages/ directory
	load_theme_textdomain( 'drk', get_template_directory() . '/languages' );
?>