• 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

このWikiはいつでも誰でも編集できます

「関数リファレンス/comment form」の版間の差分

提供: WordPress Codex 日本語版
移動先: 案内検索
(日本語版向けに調整)
(翻訳(かなり無理やり、途中))
1行目: 1行目:
{{Stub}}
+
== 概要 ==
{{NeedTrans}}
+
{{テンプレートタグガイド|PHP}}
+
 
+
== Description ==
+
  
 
This tag outputs a complete commenting form for use within a [[Templates|template]].
 
This tag outputs a complete commenting form for use within a [[Templates|template]].
 +
 +
このタグは、[[Templates|template]]の内で完全なコメントフォームを出力します。
  
 
Most strings and form fields may be controlled through the [[#$args|$args]] array passed into the function, while you may also choose to use the <code>comments_form_default_fields</code> [[Plugin API|filter]] to modify the [[#$args|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 <code>comments_form_field_''$name''</code> where <code>$name</code> is the key used in the array of fields.
 
Most strings and form fields may be controlled through the [[#$args|$args]] array passed into the function, while you may also choose to use the <code>comments_form_default_fields</code> [[Plugin API|filter]] to modify the [[#$args|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 <code>comments_form_field_''$name''</code> where <code>$name</code> is the key used in the array of fields.
  
== Usage ==
+
== 使い方 ==
  
 
  <?php comment_form( $args, $post_id ); ?>
 
  <?php comment_form( $args, $post_id ); ?>
  
=== Default Usage ===
+
=== デフォルトの設定 ===
  
 
[[Image:twentytendefault6.png|thumb]]
 
[[Image:twentytendefault6.png|thumb]]
21行目: 19行目:
 
cf. {{Source|wp-content/themes/twentyten/comments.php}}
 
cf. {{Source|wp-content/themes/twentyten/comments.php}}
  
== Parameters ==
+
== パラメータ ==
  
 
{{Parameter|[[#$args|args]]|array|Options for strings, fields etc in the form.|optional|([[#$args|See below]])}}
 
{{Parameter|[[#$args|args]]|array|Options for strings, fields etc in the form.|optional|([[#$args|See below]])}}
28行目: 26行目:
 
=== $args ===
 
=== $args ===
  
Default value:
+
default value デフォルト値:
 
<pre>
 
<pre>
 
<?php $defaults = array(
 
<?php $defaults = array(
48行目: 46行目:
  
 
{{Parameter|fields|array|Input fields other than comment body, such as author, email, url.|optional|<code>apply_filters( 'comment_form_default_fields', [[#$fields|$fields]] )</code>}}
 
{{Parameter|fields|array|Input fields other than comment body, such as author, email, url.|optional|<code>apply_filters( 'comment_form_default_fields', [[#$fields|$fields]] )</code>}}
{{Parameter|comment_field|string|The textarea and the label of comment body.|optional|<!-- default -->}}
+
{{Parameter|comment_field|文字列|The textarea and the label of comment body.|optional|<!-- default -->}}
{{Parameter|must_log_in|string|<!--description-->|optional|<!-- default -->}}
+
{{Parameter|must_log_in|文字列|<!--description-->|optional|<!-- default -->}}
{{Parameter|logged_in_as|string|<!--description-->|optional|<!-- default -->}}
+
{{Parameter|logged_in_as|文字列|<!--description-->|optional|<!-- default -->}}
{{Parameter|comment_notes_before|string|text or html tags befor comment form.|optional|<!-- default -->}}
+
{{Parameter|comment_notes_before|文字列|text or html tags befor comment form.|optional|<!-- default -->}}
{{Parameter|comment_notes_after|string|text or html tags after comment body.|optional|<!-- default -->}}
+
{{Parameter|comment_notes_after|文字列|text or html tags after comment body.|optional|<!-- default -->}}
{{Parameter|id_form|string|value of the <code>id</code> attribute of <code>form</code> element (<code><nowiki><form></nowiki></code> tag).|optional|'commentform'}}
+
{{Parameter|id_form|文字列|value of the <code>id</code> attribute of <code>form</code> element (<code><nowiki><form></nowiki></code> tag).|optional|'commentform'}}
{{Parameter|id_submit|string|value of the <code>id</code> attribute of submit button.|optional|'submit'}}
+
{{Parameter|id_submit|文字列|value of the <code>id</code> attribute of submit button.|optional|'submit'}}
{{Parameter|title_reply|string|The title of comment form.|optional|[[関数リファレンス/_2|__]]( 'Leave a Reply' )}}
+
{{Parameter|title_reply|文字列|The title of comment form.|optional|[[関数リファレンス/_2|__]]( 'Leave a Reply' )}}
{{Parameter|title_reply_to|string|<!--description-->|optional|[[関数リファレンス/_2|__]]( 'Leave a Reply to %s' )}}
+
{{Parameter|title_reply_to|文字列|<!--description-->|optional|[[関数リファレンス/_2|__]]( 'Leave a Reply to %s' )}}
{{Parameter|cancel_reply_link|string|link label to cancel reply.|optional|[[関数リファレンス/_2|__]]( 'Cancel reply' )}}
+
{{Parameter|cancel_reply_link|文字列|link label to cancel reply.|optional|[[関数リファレンス/_2|__]]( 'Cancel reply' )}}
{{Parameter|label_submit|string|the name of submit button.|optional|[[関数リファレンス/_2|__]]( 'Post Comment' )}}
+
{{Parameter|label_submit|文字列|the name of submit button.|optional|[[関数リファレンス/_2|__]]( 'Post Comment' )}}
  
 
=== $fields ===
 
=== $fields ===
84行目: 82行目:
 
=== customizing Input Fields ===
 
=== customizing Input Fields ===
  
== Changelog ==
+
== 変更履歴 ==
  
* Since [[Version 3.0|3.0.0]]
+
* [[Version 3.0|3.0.0]] : 新規テンプレートタグ
  
 
== Source Code ==
 
== Source Code ==

2010年11月1日 (月) 10:32時点における版

概要

This tag outputs a complete commenting form for use within a template.

このタグは、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 comments_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 comments_form_field_$name where $name is the key used in the array of fields.

使い方

<?php comment_form( $args, $post_id ); ?>

デフォルトの設定

<?php comment_form(); ?>

cf. wp-content/themes/twentyten/comments.php

パラメータ

args
array) (optional) Options for strings, fields etc in the form.
初期値: (See below)
post_id
mixed) (optional) Post ID to generate the form for, uses the current post if null
初期値: null (the current post)

$args

default value デフォルト値:

<?php $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.' ), wp_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, wp_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' ),
);
?>
fields
array) (optional) Input fields other than comment body, such as author, email, url.
初期値: apply_filters( 'comment_form_default_fields', $fields )
comment_field
文字列) (optional) The textarea and the label of comment body.
初期値:
must_log_in
文字列) (optional
初期値:
logged_in_as
文字列) (optional
初期値:
comment_notes_before
文字列) (optional) text or html tags befor comment form.
初期値:
comment_notes_after
文字列) (optional) text or html tags after comment body.
初期値:
id_form
文字列) (optional) value of the id attribute of form element (<form> tag).
初期値: 'commentform'
id_submit
文字列) (optional) value of the id attribute of submit button.
初期値: 'submit'
title_reply
文字列) (optional) The title of comment form.
初期値: __( 'Leave a Reply' )
title_reply_to
文字列) (optional
初期値: __( 'Leave a Reply to %s' )
cancel_reply_link
文字列) (optional) link label to cancel reply.
初期値: __( 'Cancel reply' )
label_submit
文字列) (optional) the name of submit button.
初期値: __( 'Post Comment' )

$fields

Default input items:

<?php
$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>',
); ?>

Return

void

Filter

Examples

customizing Input Fields

変更履歴

  • 3.0.0 : 新規テンプレートタグ

Source Code

comment_form() is located in wp-includes/comment-template.php.

最新英語版: WordPress Codex » Template Tags/comment_form最新版との差分

Related

テンプレート:Comments Tags


関数リファレンステンプレートタグ目次もご覧ください。