<?php
//funkcje bezpieczeństwa - snippet
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die('Nie możesz bezpośrednio uruchomić tego pliku.');
if (post_password_required()) {
echo 'Post jest chroniony hasłem. Wprowadź hasło aby zobaczyć komentarze.';
return;
}
?>
<div class="comments">
<?php if(!comments_open()) : ?>
<h2>Post nie pozwala na dodawanie komentarzy</h2>
<?php else: ?>
<header>
<h2>Komentarze</h2>
<h3>Co myślą inni?</h3>
</header>
<div class="comments-list">
<?php if(have_comments()) : ?>
<?php wp_list_comments(array(
'callback' => 'lovetoeat_comment_theme',
'style' => 'div',
'avatar_size' => 69
));?>
<?php else: ?>
<p class="no-comments">Ten wpis nie posiada jeszcze żadnych komentrzy.</p>
<?php endif; ?>
</div>
<?php if (get_comment_pages_count() > 1 && get_option('page_comments') ) : ?>
<div class="comments-navi">
<div class="prev"><?php echo previous_comments_link('Starsze komentarze'); ?></div>
<div class="next"><?php echo next_comments_link('Nowsze komentarze'); ?></div>
</div>
<?php endif; ?>
<div id="respond">
<header>
<h2>
<?php comment_form_title('Dodaj komentarz','Odpowiedz dla %s');?>
<?php cancel_comment_reply_link('Kliknij tutaj, aby anulować odpowiadanie.');?>
</h2>
<h3>Masz jakiś pomysł?</h3>
</header>
<?php if( get_option('comment_registration') && !is_user_logged_in() ) : ?>
<p>Musisz sie <a href="<?php echo wp_login_url(get_permalink());?>">zalogowac</a></p>
<?php else :?>
<form id="commentform" method="post" action="<?php echo get_option('siteurl');?>/wp-comments-post.php">
<?php if(is_user_logged_in()) : ?>
<p>Zalogowany jako: <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>">Wyloguj sie</a></p>
<?php else: ?>
<input type="text" name="author" placeholder="Imię i nazwisko">
<input type="text" name="email" placeholder="Adres e-mail">
<?php endif; ?>
<textarea name="comment" placeholder="Treść komentarza"></textarea>
<?php comment_id_fields(); ?>
<button>Wyślij</button>
<?php do_action('comment_form', $post->ID); ?>
</form>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
----------------------Functions.php---------------------------------------------------
<?php
function lovetoeat_comment_theme($comment, $args, $depth){
$GLOBALS['comment'] = $comment; // globalny obiekt komentarza
$tag = $args['style'];
?>
<<?php echo $tag; ?> <?php comment_class(empty($args['has_children']) ? '' : 'parent') ?> id="li-comment-<?php comment_ID() ?>">
<div id="div-comment-<?php comment_ID(); ?>" class="inner">
<?php echo get_avatar($comment, $args[avatar_size]); ?>
<h4>
<?php echo get_comment_author();?>
<?php echo 'w dniu ' . get_comment_date() . ' o ' . get_comment_time() ?>
<?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</h4>
<?php comment_text(); ?>
<?php if($comment->comment_approved == '0') : ?>
<div class="comment_awaiting_moderation">Twoj komentarz oczekuje na moderacje!</div>
<?php endif;?>
</div>
<?php
}
?>
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.