hangar-wp-theme/hangar/library/comments-extensions.php

94 lines
3.4 KiB
PHP
Raw Permalink Normal View History

2021-02-18 14:09:56 +01:00
<?php
/* permetre comentaris només als blocs */
add_filter( 'comments_open', 'open_comments_for_cat', 10, 2 );
function open_comments_for_cat( $open, $post_id )
{
$categories = (array (30,3,4));
if( in_category( $categories, $post_id ) ) :
return true;
elseif (post_is_in_descendant_category( $categories, $post_id ) ) :
return true;
else:
return $open;
endif;
}
if ( ! function_exists( 'ari_comment' ) ) :
/* Search form custom styling */
function ari_search_form( $form ) {
$form = '<form role="search" method="get" id="searchform" action="'.get_bloginfo('url').'" >
<div><label class="screen-reader-text" for="s">' . __('') . '</label>
<input type="submit" id="searchsubmit" value="'. esc_attr__('Search', 'hangar') .'" />
<input type="text" class="search-input" value="' . get_search_query() . '" name="s" id="s" />
</div>
</form>';
return $form;
}
add_filter( 'get_search_form', 'ari_search_form' );
/* Template for comments and pingbacks. */
function ari_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case '' :
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="comment-body">
<div class="comment-meta commentmetadata"><?php printf( '<span class="fn">%s</span>', get_comment_author_link() ) ; ?> <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"> -
<?php
/* translators: 1: date, 2: time */
printf( __( '%1$s at %2$s', 'hangar' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( 'Edit &rarr;', 'hangar' ), ' ' );
?>
</div><!-- .comment-meta .commentmetadata -->
<?php comment_text(); ?>
<?php if ( $comment->comment_approved == '0' ) : ?>
<p class="moderation"><?php _e( 'Your comment is awaiting moderation.', 'hangar' ); ?></p>
<?php endif; ?>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div><!-- .reply -->
</div>
<!--comment Body-->
</div><!-- #comment-## -->
<?php
break;
case 'pingback' :
case 'trackback' :
?>
<li class="post pingback">
<p><?php _e( 'Pingback:', 'hangar' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'hangar'), ' ' ); ?></p>
<?php
break;
endswitch;
}
endif;
/* Comments Form Filters */
function ari_fields($fields) {
$fields['url'] = '<p class="comment-form-url"><label for="url">' . __( 'Website', 'hangar') . '</label>' .
'<br/><input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>';
$fields['email'] = '<p class="comment-form-email"><label for="email">' . __( 'Email*', 'hangar') . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
'<br/><input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>';
$fields['author'] = '<p class="comment-form-author">' . '<label for="author">' . __( 'Name*', 'hangar') . '</label> ' . ( $req ? '<span class="required">*</span>' : '') .
'<br/><input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>';
return $fields;
}
add_filter('comment_form_default_fields','ari_fields');
?>