<?php 
// style do blog

function style_or_min_style() {
    $located = locate_template( 'style.min.css' );
     if ($located != '' ) {
          echo '<link rel="stylesheet" href="'.get_template_directory_uri().'/style.min.css" />';
     } else {
          echo '<link rel="stylesheet" href="'.get_template_directory_uri().'/style.css" />';
     }
}

// registro de sidebar

 if ( function_exists('register_sidebar') ) {
   register_sidebar(array(
   'name' => 'Lateral',
'id' => 'Lateral',
'before_widget' => '<div class="widget">',
'after_widget'  => '</div>',
    ));
}

 // mensagem footer
 
function remove_footer_admin () {
    echo "cores, flores & amores &hearts;";
}
add_filter('admin_footer_text', 'remove_footer_admin');

function change_footer_version() {
  return 'Programação feita com amor por Ella Jardim &hearts;';
}
add_filter( 'update_footer', 'change_footer_version', 9999 );

// registro de menu
 
 function register_my_menus() {
  register_nav_menus(
    array(
      'menu' => __( 'Menu Principal' )
    )
  );
}
add_action( 'init', 'register_my_menus' );

// retorno de pagina inicial na marca de login
function loginpage_custom_link() {
    return get_bloginfo('url');
}
add_filter('login_headerurl','loginpage_custom_link');
 
// mudar o nome do titulo alt de header de login (marca)
function change_title_on_logo() {
    return 'Voltar para ' . get_bloginfo('name');
}
add_filter('login_headertitle', 'change_title_on_logo');


// executa php nos widgets
add_filter('widget_text','execute_php',100);
function execute_php($html){
     if(strpos($html,"<"."?php")!==false){
          ob_start();
          eval("?".">".$html);
          $html=ob_get_contents();
          ob_end_clean();
     }
     return $html;
}

// resumos em paginas
 
add_action( 'init', 'my_add_excerpts_to_pages' );
function my_add_excerpts_to_pages() {
     add_post_type_support( 'page', 'excerpt' );
}

// registro de tamanhos de miniaturas
 
if ( function_exists( 'add_theme_support' ) ) :
add_theme_support( 'post-thumbnails' );
add_image_size( 'relacionados', 200, 200, array( 'center', 'center' ) );
add_image_size( 'excerpt-thumb', 402, 287, array( 'center', 'center' ) );
endif; 

 // comentarios
 
function mytheme_comment($comment, $args, $depth) {
    $GLOBALS['comment'] = $comment;
    extract($args, EXTR_SKIP);

    if ( 'div' == $args['style'] ) {
        $tag = 'div';
        $add_below = 'comment';
    } else {
        $tag = 'li';
        $add_below = 'div-comment';
    }
            ?>
<<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
    <?php if ( 'div' != $args['style'] ) : ?>
    <div id="div-comment-<?php comment_ID() ?>" class="comment-body">
    <?php endif; ?>
<div class="avatar"><?php echo get_avatar( $comment, 40 ); ?></div>
<div class="info-comment"><a href="<?php comment_author_url(); ?>"><b><?php comment_author()?></b></a> <span class="comment-date"> em <?php comment_time('j \d\e F \d\e Y', '', ''); ?></span>
</div>

<div class="comment-text">
           <?php if ($comment->comment_approved == '0') : ?>
    <em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em>
    <br />
           <?php endif; ?>
    <?php comment_text() ?>
	
    <div class="reply"><i class="fa fa-reply" aria-hidden="true"></i> <span><?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?></span>
   <div class="clear"></div>

</div>
</div>
    <?php if ( 'div' != $args['style'] ) : ?>
    </div>
    <?php endif; ?>
            <?php
            }
?>