Created
October 14, 2015 07:52
-
-
Save phlbnks/8b4cf47f530d4119fe4f to your computer and use it in GitHub Desktop.
Only show Crowd Control's "report" link when users logged in if "Users must be registered and logged in to comment" is set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* add_flagging_link_comment - Add report link to comment content | |
* | |
* Add report link to comment content | |
* | |
* @since 1.0 | |
* | |
* @param string $comment_text | |
* @param object $comment | |
* | |
* @returns string $comment_test | |
*/ | |
public function add_flagging_link_comment( $comment_text, $comment = '' ) { | |
if ( $this->is_admin() || $this->already_flagged( $comment->comment_ID ) || ( get_option( 'comment_registration' ) && !$this->is_user_logged_in() ) ) return $comment_text; | |
$nonce = wp_create_nonce( 'pmcc_comment_' . $comment->comment_ID ); | |
$html = $comment_text . sprintf( '<span class="pmcc-comments-report-link" id="comment-%1$d"><a class="hide-if-no-js" href="javascript:void(0);" onclick="crowd_control_comments_flag_comment( \'%1$d\', \'%4$s\', \'%2$d\');">%3$s</a></span>', $comment->comment_ID, $comment->comment_post_ID, esc_html__( 'Report', 'crowd-control' ), $nonce ); | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment