2231 | | if ( comments_open( $post_id ) ) : ?> |
2232 | | <?php |
2233 | | /** |
2234 | | * Fires before the comment form. |
2235 | | * |
2236 | | * @since 3.0.0 |
2237 | | */ |
2238 | | do_action( 'comment_form_before' ); |
2239 | | ?> |
2240 | | <div id="respond" class="comment-respond"> |
2241 | | <h3 id="reply-title" class="comment-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> |
2242 | | <?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?> |
2243 | | <?php echo $args['must_log_in']; ?> |
| 2236 | if ( comments_open( $post_id ) ) : ?> |
| 2237 | <?php |
| 2238 | /** |
| 2239 | * Fires before the comment form. |
| 2240 | * |
| 2241 | * @since 3.0.0 |
| 2242 | */ |
| 2243 | do_action( 'comment_form_before' ); |
| 2244 | ?> |
| 2245 | <div id="<?php echo esc_attr( get_comment_container_id( false ) ); ?>" class="comment-respond"> |
| 2246 | <h3 id="<?php echo esc_attr( $args [ 'reply_title_id' ] ); ?>" class="comment-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> |
| 2247 | <?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?> |
| 2248 | <?php echo $args['must_log_in']; ?> |
| 2249 | <?php |
| 2250 | /** |
| 2251 | * Fires after the HTML-formatted 'must log in after' message in the comment form. |
| 2252 | * |
| 2253 | * @since 3.0.0 |
| 2254 | */ |
| 2255 | do_action( 'comment_form_must_log_in_after' ); |
| 2256 | ?> |
| 2257 | <?php else : ?> |
| 2258 | <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="comment-form"<?php echo $html5 ? ' novalidate' : ''; ?>> |
2262 | | <?php if ( is_user_logged_in() ) : ?> |
2263 | | <?php |
2264 | | /** |
2265 | | * Filter the 'logged in' message for the comment form for display. |
2266 | | * |
2267 | | * @since 3.0.0 |
2268 | | * |
2269 | | * @param string $args_logged_in The logged-in-as HTML-formatted message. |
2270 | | * @param array $commenter An array containing the comment author's |
2271 | | * username, email, and URL. |
2272 | | * @param string $user_identity If the commenter is a registered user, |
2273 | | * the display name, blank otherwise. |
2274 | | */ |
2275 | | echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); |
2276 | | ?> |
2277 | | <?php |
2278 | | /** |
2279 | | * Fires after the is_user_logged_in() check in the comment form. |
2280 | | * |
2281 | | * @since 3.0.0 |
2282 | | * |
2283 | | * @param array $commenter An array containing the comment author's |
2284 | | * username, email, and URL. |
2285 | | * @param string $user_identity If the commenter is a registered user, |
2286 | | * the display name, blank otherwise. |
2287 | | */ |
2288 | | do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); |
2289 | | ?> |
2290 | | <?php else : ?> |
2291 | | <?php echo $args['comment_notes_before']; ?> |
2292 | | <?php |
2293 | | /** |
2294 | | * Fires before the comment fields in the comment form. |
2295 | | * |
2296 | | * @since 3.0.0 |
2297 | | */ |
2298 | | do_action( 'comment_form_before_fields' ); |
2299 | | foreach ( (array) $args['fields'] as $name => $field ) { |
2300 | | /** |
2301 | | * Filter a comment form field for display. |
2302 | | * |
2303 | | * The dynamic portion of the filter hook, `$name`, refers to the name |
2304 | | * of the comment form field. Such as 'author', 'email', or 'url'. |
2305 | | * |
2306 | | * @since 3.0.0 |
2307 | | * |
2308 | | * @param string $field The HTML-formatted output of the comment form field. |
2309 | | */ |
2310 | | echo apply_filters( "comment_form_field_{$name}", $field ) . "\n"; |
2311 | | } |
2312 | | /** |
2313 | | * Fires after the comment fields in the comment form. |
2314 | | * |
2315 | | * @since 3.0.0 |
2316 | | */ |
2317 | | do_action( 'comment_form_after_fields' ); |
2318 | | ?> |
2319 | | <?php endif; ?> |
2339 | | * @since 1.5.0 |
| 2301 | * @since 3.0.0 |
| 2302 | */ |
| 2303 | do_action( 'comment_form_before_fields' ); |
| 2304 | foreach ( (array) $args['fields'] as $name => $field ) { |
| 2305 | /** |
| 2306 | * Filter a comment form field for display. |
| 2307 | * |
| 2308 | * The dynamic portion of the filter hook, `$name`, refers to the name |
| 2309 | * of the comment form field. Such as 'author', 'email', or 'url'. |
| 2310 | * |
| 2311 | * @since 3.0.0 |
| 2312 | * |
| 2313 | * @param string $field The HTML-formatted output of the comment form field. |
| 2314 | */ |
| 2315 | echo apply_filters( "comment_form_field_{$name}", $field ) . "\n"; |
| 2316 | } |
| 2317 | /** |
| 2318 | * Fires after the comment fields in the comment form. |
2345 | | </form> |
2346 | | <?php endif; ?> |
2347 | | </div><!-- #respond --> |
2348 | | <?php |
2349 | | /** |
2350 | | * Fires after the comment form. |
2351 | | * |
2352 | | * @since 3.0.0 |
2353 | | */ |
2354 | | do_action( 'comment_form_after' ); |
2355 | | else : |
2356 | | /** |
2357 | | * Fires after the comment form if comments are closed. |
2358 | | * |
2359 | | * @since 3.0.0 |
2360 | | */ |
2361 | | do_action( 'comment_form_comments_closed' ); |
2362 | | endif; |
| 2324 | <?php endif; ?> |
| 2325 | <?php |
| 2326 | /** |
| 2327 | * Filter the content of the comment textarea field for display. |
| 2328 | * |
| 2329 | * @since 3.0.0 |
| 2330 | * |
| 2331 | * @param string $args_comment_field The content of the comment textarea field. |
| 2332 | */ |
| 2333 | echo apply_filters( 'comment_form_field_comment', $args['comment_field'] ); |
| 2334 | ?> |
| 2335 | <?php echo $args['comment_notes_after']; ?> |
| 2336 | <p class="form-submit"> |
| 2337 | <input name="<?php echo esc_attr( $args['name_submit'] ); ?>" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>" class="<?php echo esc_attr( $args['class_submit'] ); ?>" value="<?php echo esc_attr( $args['label_submit'] ); ?>" /> |
| 2338 | <?php comment_id_fields( $post_id ); ?> |
| 2339 | </p> |
| 2340 | <?php |
| 2341 | /** |
| 2342 | * Fires at the bottom of the comment form, inside the closing </form> tag. |
| 2343 | * |
| 2344 | * @since 1.5.0 |
| 2345 | * |
| 2346 | * @param int $post_id The post ID. |
| 2347 | */ |
| 2348 | do_action( 'comment_form', $post_id ); |
| 2349 | ?> |
| 2350 | </form> |
| 2351 | <?php endif; ?> |
| 2352 | </div><!-- #respond --> |
| 2353 | <?php |
| 2354 | /** |
| 2355 | * Fires after the comment form. |
| 2356 | * |
| 2357 | * @since 3.0.0 |
| 2358 | */ |
| 2359 | do_action( 'comment_form_after' ); |
| 2360 | else : |
| 2361 | /** |
| 2362 | * Fires after the comment form if comments are closed. |
| 2363 | * |
| 2364 | * @since 3.0.0 |
| 2365 | */ |
| 2366 | do_action( 'comment_form_comments_closed' ); |
| 2367 | endif; |
| 2369 | |
| 2370 | /** |
| 2371 | * Returns the ID to use for the comment from container. |
| 2372 | * |
| 2373 | * Can be used in HTML, when $with_hash is false, or to target the container in JavaScript, when $with_hash is true. |
| 2374 | * |
| 2375 | * @since 4.2.0 |
| 2376 | * |
| 2377 | * @param bool $with_hash Optional. Whether to return with a hash (#) or not. Default is true. |
| 2378 | * |
| 2379 | * @return string |
| 2380 | */ |
| 2381 | function get_comment_container_id( $with_hash = true ) { |
| 2382 | |
| 2383 | /** |
| 2384 | * Modify the ID used for the comment reply container |
| 2385 | * |
| 2386 | * @since 4.2.0 |
| 2387 | * |
| 2388 | * @param string $reply_id The ID to use |
| 2389 | */ |
| 2390 | $reply_id = apply_filters( 'comment_container_id', 'respond' ); |
| 2391 | $reply_id = sanitize_title( $reply_id, 'respond' ); |
| 2392 | if ( $with_hash ) { |
| 2393 | if ( ! strpos( $reply_id, '#' ) ) { |
| 2394 | $reply_id = '#' . $reply_id; |
| 2395 | } |
| 2396 | } else { |
| 2397 | if ( strpos( $reply_id, '#' ) ) { |
| 2398 | $reply_id = str_replace( '#', '', $reply_id ); |
| 2399 | } |
| 2400 | } |
| 2401 | |
| 2402 | return $reply_id; |
| 2403 | |
| 2404 | } |