예제 #1
0
 function woo_comment_form_fields($fields)
 {
     $commenter = nxt_get_current_commenter();
     $required_text = ' <span class="required">(' . __('Required', 'woothemes') . ')</span>';
     $req = get_option('require_name_email');
     $aria_req = $req ? " aria-required='true'" : '';
     $fields = array('author' => '<p class="comment-form-author">' . '<input id="author" class="txt" name="author" type="text" value="' . esc_attr($commenter['comment_author']) . '" size="30"' . $aria_req . ' />' . '<label for="author">' . __('Name', 'woothemes') . ($req ? $required_text : '') . '</label> ' . '</p>', 'email' => '<p class="comment-form-email">' . '<input id="email" class="txt" name="email" type="text" value="' . esc_attr($commenter['comment_author_email']) . '" size="30"' . $aria_req . ' />' . '<label for="email">' . __('Email', 'woothemes') . ($req ? $required_text : '') . '</label> ' . '</p>', 'url' => '<p class="comment-form-url">' . '<input id="url" class="txt" name="url" type="text" value="' . esc_attr($commenter['comment_author_url']) . '" size="30" />' . '<label for="url">' . __('Website', 'woothemes') . '</label>' . '</p>');
     return $fields;
 }
예제 #2
0
 /**
  * Applies BuddyPress customisations to the post comment form.
  *
  * @global string $user_identity The display name of the user
  * @param array $default_labels The default options for strings, fields etc in the form
  * @see comment_form()
  * @since 1.5
  */
 function bp_dtheme_comment_form($default_labels)
 {
     global $user_identity;
     $commenter = nxt_get_current_commenter();
     $req = get_option('require_name_email');
     $aria_req = $req ? " aria-required='true'" : '';
     $fields = array('author' => '<p class="comment-form-author">' . '<label for="author">' . __('Name', 'buddypress') . ($req ? '<span class="required"> *</span>' : '') . '</label> ' . '<input id="author" name="author" type="text" value="' . esc_attr($commenter['comment_author']) . '" size="30"' . $aria_req . ' /></p>', 'email' => '<p class="comment-form-email"><label for="email">' . __('Email', 'buddypress') . ($req ? '<span class="required"> *</span>' : '') . '</label> ' . '<input id="email" name="email" type="text" value="' . esc_attr($commenter['comment_author_email']) . '" size="30"' . $aria_req . ' /></p>', 'url' => '<p class="comment-form-url"><label for="url">' . __('Website', 'buddypress') . '</label>' . '<input id="url" name="url" type="text" value="' . esc_attr($commenter['comment_author_url']) . '" size="30" /></p>');
     $new_labels = array('comment_field' => '<p class="form-textarea"><textarea name="comment" id="comment" cols="60" rows="10" aria-required="true"></textarea></p>', 'fields' => apply_filters('comment_form_default_fields', $fields), 'logged_in_as' => '', 'must_log_in' => '<p class="alert">' . sprintf(__('You must be <a href="%1$s">logged in</a> to post a comment.', 'buddypress'), nxt_login_url(get_permalink())) . '</p>', 'title_reply' => __('Leave a reply', 'buddypress'));
     return apply_filters('bp_dtheme_comment_form', array_merge($default_labels, $new_labels));
 }
예제 #3
0
/**
 * Outputs a complete commenting form for use within a template.
 * Most strings and form fields may be controlled through the $args array passed
 * into the function, while you may also choose to use the comment_form_default_fields
 * filter to modify the array of default fields if you'd just like to add a new
 * one or remove a single field. All fields are also individually passed through
 * a filter of the form comment_form_field_$name where $name is the key used
 * in the array of fields.
 *
 * @since 3.0.0
 * @param array $args Options for strings, fields etc in the form
 * @param mixed $post_id Post ID to generate the form for, uses the current post if null
 * @return void
 */
function comment_form($args = array(), $post_id = null)
{
    global $id;
    if (null === $post_id) {
        $post_id = $id;
    } else {
        $id = $post_id;
    }
    $commenter = nxt_get_current_commenter();
    $user = nxt_get_current_user();
    $user_identity = !empty($user->ID) ? $user->display_name : '';
    $req = get_option('require_name_email');
    $aria_req = $req ? " aria-required='true'" : '';
    $fields = array('author' => '<p class="comment-form-author">' . '<label for="author">' . __('Name') . '</label> ' . ($req ? '<span class="required">*</span>' : '') . '<input id="author" name="author" type="text" value="' . esc_attr($commenter['comment_author']) . '" size="30"' . $aria_req . ' /></p>', 'email' => '<p class="comment-form-email"><label for="email">' . __('Email') . '</label> ' . ($req ? '<span class="required">*</span>' : '') . '<input id="email" name="email" type="text" value="' . esc_attr($commenter['comment_author_email']) . '" size="30"' . $aria_req . ' /></p>', 'url' => '<p class="comment-form-url"><label for="url">' . __('Website') . '</label>' . '<input id="url" name="url" type="text" value="' . esc_attr($commenter['comment_author_url']) . '" size="30" /></p>');
    $required_text = sprintf(' ' . __('Required fields are marked %s'), '<span class="required">*</span>');
    $defaults = array('fields' => apply_filters('comment_form_default_fields', $fields), 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x('Comment', 'noun') . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>', 'must_log_in' => '<p class="must-log-in">' . sprintf(__('You must be <a href="%s">logged in</a> to post a comment.'), nxt_login_url(apply_filters('the_permalink', get_permalink($post_id)))) . '</p>', 'logged_in_as' => '<p class="logged-in-as">' . sprintf(__('Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>'), admin_url('profile.php'), $user_identity, nxt_logout_url(apply_filters('the_permalink', get_permalink($post_id)))) . '</p>', 'comment_notes_before' => '<p class="comment-notes">' . __('Your email address will not be published.') . ($req ? $required_text : '') . '</p>', 'comment_notes_after' => '<p class="form-allowed-tags">' . sprintf(__('You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s'), ' <code>' . allowed_tags() . '</code>') . '</p>', 'id_form' => 'commentform', 'id_submit' => 'submit', 'title_reply' => __('Leave a Reply'), 'title_reply_to' => __('Leave a Reply to %s'), 'cancel_reply_link' => __('Cancel reply'), 'label_submit' => __('Post Comment'));
    $args = nxt_parse_args($args, apply_filters('comment_form_defaults', $defaults));
    ?>
		<?php 
    if (comments_open()) {
        ?>
			<?php 
        do_action('comment_form_before');
        ?>
			<div id="respond">
				<h3 id="reply-title"><?php 
        comment_form_title($args['title_reply'], $args['title_reply_to']);
        ?>
 <small><?php 
        cancel_comment_reply_link($args['cancel_reply_link']);
        ?>
</small></h3>
				<?php 
        if (get_option('comment_registration') && !is_user_logged_in()) {
            ?>
					<?php 
            echo $args['must_log_in'];
            ?>
					<?php 
            do_action('comment_form_must_log_in_after');
            ?>
				<?php 
        } else {
            ?>
					<form action="<?php 
            echo site_url('/nxt-comments-post.php');
            ?>
" method="post" id="<?php 
            echo esc_attr($args['id_form']);
            ?>
">
						<?php 
            do_action('comment_form_top');
            ?>
						<?php 
            if (is_user_logged_in()) {
                ?>
							<?php 
                echo apply_filters('comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity);
                ?>
							<?php 
                do_action('comment_form_logged_in_after', $commenter, $user_identity);
                ?>
						<?php 
            } else {
                ?>
							<?php 
                echo $args['comment_notes_before'];
                ?>
							<?php 
                do_action('comment_form_before_fields');
                foreach ((array) $args['fields'] as $name => $field) {
                    echo apply_filters("comment_form_field_{$name}", $field) . "\n";
                }
                do_action('comment_form_after_fields');
                ?>
						<?php 
            }
            ?>
						<?php 
            echo apply_filters('comment_form_field_comment', $args['comment_field']);
            ?>
						<?php 
            echo $args['comment_notes_after'];
            ?>
						<p class="form-submit">
							<input name="submit" type="submit" id="<?php 
            echo esc_attr($args['id_submit']);
            ?>
" value="<?php 
            echo esc_attr($args['label_submit']);
            ?>
" />
							<?php 
            comment_id_fields($post_id);
            ?>
						</p>
						<?php 
            do_action('comment_form', $post_id);
            ?>
					</form>
				<?php 
        }
        ?>
			</div><!-- #respond -->
			<?php 
        do_action('comment_form_after');
        ?>
		<?php 
    } else {
        ?>
			<?php 
        do_action('comment_form_comments_closed');
        ?>
		<?php 
    }
    ?>
	<?php 
}