Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_post_reply_link [ WordPress Function ]

get_post_reply_link ( $args = array(), $post = null )
Parameters:
  • (array) $args Optional. Override default options.
  • (int|object) $post Optional. Post that the comment is going to be displayed on. Defaults to current post.
Returns:
  • (string|bool|null) Link to show comment form, if successful. False, if comments are closed.
Defined at:



Retrieve HTML content for reply to post link.

The default arguments that can be override are 'add_below', 'respond_id', 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be used, if the user must log in or register first before posting a comment. The 'reply_text' will be used, if they can post a reply. The 'add_below' and 'respond_id' arguments are for the JavaScript moveAddCommentForm() function parameters.

Source


<?php
function get_post_reply_link($args = array(), $post null) {
    global 
$user_ID;

    
$defaults = array('add_below' => 'post''respond_id' => 'respond''reply_text' => __('Leave a Comment'),
        
'login_text' => __('Log in to leave a Comment'), 'before' => '''after' => '');

    
$args wp_parse_args($args$defaults);
    
extract($argsEXTR_SKIP);
    
$post get_post($post);

    if ( !
comments_open($post->ID) )
        return 
false;

    if ( 
get_option('comment_registration') && !$user_ID ) {
        
$link '<a rel="nofollow" href="' wp_login_urlget_permalink() ) . '">' $login_text '</a>';
    } else {
        
$link "<a rel='nofollow' class='comment-reply-link' href='" get_permalink($post->ID) . "#$respond_id' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"0\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";
    }
    return 
apply_filters('post_comments_link'$before $link $after$post);
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics