<?php
/* functions.php */

function dg_scripts()
{

//  CSS STYLESHEETS

  wp_enqueue_style("dg-style",get_template_directory_uri().'/css/style.css');
  wp_enqueue_style("bt-style",get_template_directory_uri().'/css/bootstrap.css');
  wp_enqueue_style("bt-style",get_template_directory_uri().'/css/bootstrap-theme.css');
  
// JAVASCRIPT FILES

  wp_enqueue_script("jquery-script",get_template_directory_uri().'/js/jquery.min.js');
  wp_enqueue_script("bt-script",get_template_directory_uri().'/js/bootstrap.js');
  if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
		wp_enqueue_script( 'comment-reply' );
}
add_filter("wp_enqueue_scripts","dg_scripts");

// pagination 
function dg_pagination()
{
  global $wp_query;
  $big=999999999;
  echo paginate_links(array(
    'base'=>str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
	'format'=>'paged=%#%',
	'current'=>max(1,get_query_var('paged')),
	'total'=>$wp_query->max_num_pages,
	'type'=>'list'
  ));
}

// nav-menu and widget supports
function dg_after_setup()
{
  register_nav_menu("primary",__("Primary Menu",'dg'));
  
  register_sidebar(array(
    'name'=>__("Sidebar",'dg'),
	'description'=>__('The widgets to appeared on sidebar area.','dg'),
	'id'=>'sb-1',
	'before_widget'=>'<div class="panel panel-default">',
	'after_widget'=>'</div></div><br/>',
	'before_title'=>'<div class="panel-heading"><h4 class="panel-title">',
	'after_title'=>'</h4></div><div class="panel-body">'
  ));
  
  register_sidebar(array(
    'name'=>__("Footer Sidebar",'dg'),
	'description'=>__('The widgets to appeared on footer area.','dg'),
	'id'=>'sb-2',
	'before_widget'=>'<div class="col-md-4">',
	'after_widget'=>'</div>',
	'before_title'=>'<h2>',
	'after_title'=>'</h2><hr/>'
  ));
  
  register_sidebar(array(
    'name'=>__("Sidebar 404",'dg'),
	'description'=>__('The widgets to appeared on 404 error page.','dg'),
	'id'=>'sb-3',
	'before_widget'=>'<div class="col-md-4"><div class="panel panel-info">',
	'after_widget'=>'</div></div></div>',
	'before_title'=>'<div class="panel-heading"><h4 class="panel-title">',
	'after_title'=>'</h4></div><div class="panel-body">'
  ));
  
}
add_filter("widgets_init","dg_after_setup");


//misc. function of the theme
function dg_setup()
{
  add_theme_support("post-thumbnails");
  set_post_thumbnail_size("150",'150');
  
  add_theme_support("html5",array('search-form','comment-form','comment-list'));
  
  add_theme_support("automatic-feed-links");
  
  //add_theme_support("post-formats",array('gallary','audio','video','link','status','chat'));
  
  load_theme_textdomain("dg",get_template_directory().'/languages');
  
  if ( ! isset( $content_width ) ) $content_width = 900;
  
  add_editor_style();
  add_theme_support( "custom-background", array(
    'default_color'=>'#fff'
  ) );
  add_theme_support( "custom-header", array(
    'default_color'=>'#fff',
	'text_color'=>'orange'
  ) );
  
}
add_filter("after_setup_theme","dg_setup");

// comments callback
function dg_comment($comment, $args, $depth)
{
  $GLOBALS['comment']=$comment;
  global $post;
  ?>
  <li id="comment-<?php comment_ID(); ?>" >
	   <div <?php comment_class(); ?>>
	  <div class="col-lg-3">
		<h3 class="comment-author"><?php comment_author_link(); ?></h3>
	  </div>
	  <div class="comment-meta <?php if($comment->user_id === $post->post_author){ echo 'comment-admin'; } ?> col-lg-9">
		<p><span class="post-time"><a href="#comment-<?php comment_ID(); ?>" class="text-success"><?php _e('#','');comment_ID(); ?></a> <?php printf(__("%1s @ %2s",'dg'),get_comment_date(),get_comment_time()); ?></span>
		   <span class="pull-right"><a href="?replytocom=<?php comment_ID(); ?>#respond" class="btn btn-default">Reply</a></span>
		</p>
				
		<?php comment_text(); ?>
	  </div>
	</div>
  </li>
  <?php
}


?>