<?php
/*
 * Main Functions
*/ 

function thefashblog_theme_setup() {

  // let's get language support going, if you need it
  load_theme_textdomain( 'the-fash-blog', get_template_directory() . '/library/translation' );

  // enqueue base scripts and styles
  add_action( 'wp_enqueue_scripts', 'thefashblog_scripts_and_styles', 999 );
  // ie conditional wrapper

  // launching this stuff after theme setup
  thefashblog_theme_support();

  // adding sidebars to WordPress (these are created in functions.php)
  add_action( 'widgets_init', 'thefashblog_register_sidebars' );

  /************* OEMBED SIZE OPTIONS *************/

  global $content_width;
  if ( ! isset( $content_width ) ) {
  $content_width = 640;
  }

  // Thumbnail sizes
  add_image_size( 'thefashblog-thumb-600', 600, 600, true );
  add_image_size( 'thefashblog-thumb-carousel', 800, 600, true );

} /* end thefashblog ahoy */

// let's get this party started
add_action( 'after_setup_theme', 'thefashblog_theme_setup' );


/************* THUMBNAIL SIZE OPTIONS *************/


add_filter( 'image_size_names_choose', 'thefashblog_custom_image_sizes' );
function thefashblog_custom_image_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'thefashblog-thumb-600' => __('600px by 600px','the-fash-blog'),
    ) );
}


/************* ACTIVE SIDEBARS ********************/

// Sidebars & Widgetizes Areas
function thefashblog_register_sidebars() {
  register_sidebar(array(
    'id' => 'sidebar1',
    'name' => __( 'Posts Menu Widget Area', 'the-fash-blog' ),
    'description' => __( 'The Posts Menu Widget Area.', 'the-fash-blog' ),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h4 class="widgettitle">',
    'after_title' => '</h4>',
  ));

  register_sidebar(array(
    'id' => 'sidebar2',
    'name' => __( 'Page Menu Widget Area', 'the-fash-blog' ),
    'description' => __( 'The Page Menu Widget Area.', 'the-fash-blog' ),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h4 class="widgettitle">',
    'after_title' => '</h4>',
  ));

  register_sidebar(array(
    'id' => 'footer-1',
    'name' => __( 'Footer Widget Area 1', 'the-fash-blog' ),
    'description' => __( 'The Footer Widget Area.', 'the-fash-blog' ),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h4 class="widgettitle">',
    'after_title' => '</h4>',
  ));

  register_sidebar(array(
    'id' => 'footer-2',
    'name' => __( 'Footer Widget Area 2', 'the-fash-blog' ),
    'description' => __( 'The Footer Widget Area.', 'the-fash-blog' ),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h4 class="widgettitle">',
    'after_title' => '</h4>',
  ));

  register_sidebar(array(
    'id' => 'footer-3',
    'name' => __( 'Footer Widget Area 3', 'the-fash-blog' ),
    'description' => __( 'The Footer Widget Area.', 'the-fash-blog' ),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h4 class="widgettitle">',
    'after_title' => '</h4>',
  ));

  register_sidebar(array(
    'id' => 'footer-4',
    'name' => __( 'Footer Widget Area 4', 'the-fash-blog' ),
    'description' => __( 'The Footer Widget Area.', 'the-fash-blog' ),
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h4 class="widgettitle">',
    'after_title' => '</h4>',
  ));


} // don't remove this bracket!


function thefashblog_editor_styles() {
    add_editor_style( array(
      get_template_directory_uri() . '/library/css/style.min.css',
      get_template_directory_uri() . '/fonts/fonts.css',
      get_stylesheet_uri(),
      'thefashblog-editor-style.css'
    ));
}
add_action( 'after_setup_theme', 'thefashblog_editor_styles' );

if ( ! function_exists( 'thefashblog_paging_nav' ) ) :
/**
 * Display navigation to next/previous set of posts when applicable.
 *
 */
function thefashblog_paging_nav() {
  global $wp_query;

  // Don't print empty markup if there's only one page.
  if ( $wp_query->max_num_pages < 2 )
    return;
  ?>
  <div class="next-post-pagination" role="navigation">

      <?php if ( get_next_posts_link() ) : ?>
      <?php next_posts_link( __( '&lt;&lt; Older Posts', 'the-fash-blog' ) ); ?>
      <?php endif; ?>

      <?php if ( get_previous_posts_link() ) : ?>
      <?php previous_posts_link( __( 'Newer Posts &gt;&gt;', 'the-fash-blog' ) ); ?>
      <?php endif; ?>

      <span class="clearfix"></span>
    </div>
  <?php
}
endif;

/************* COMMENT LAYOUT *********************/

// Comment Layout
function thefashblog_comments( $comment, $args, $depth ) { ?>
  <div id="comment-<?php comment_ID(); ?>" <?php comment_class('cf'); ?>>
    <article  class="cf">
      <header class="comment-author vcard">
        <?php echo get_avatar( $comment, 100 ); ?>
      </header>
      <?php if ($comment->comment_approved == '0') : ?>
        <div class="alert alert-info">
          <p><?php _e( 'Your comment is awaiting moderation.', 'the-fash-blog' ) ?></p>
        </div>
      <?php endif; ?>
      <section class="comment_content cf">
        <?php printf(__( '<cite class="fn">%1$s</cite> %2$s', 'the-fash-blog' ), get_comment_author_link(), edit_comment_link(__( '(Edit)', 'the-fash-blog' ),'  ','') ) ?>
        <br>
        <time datetime="<?php echo comment_time('Y-m-j'); ?>"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php comment_time(__( 'F jS, Y', 'the-fash-blog' )); ?> </a></time>
        <?php comment_text() ?>
        <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
      </section>
    </article>
  <?php // </li> is added by WordPress automatically ?>
<?php
} // don't remove this bracket!