Skip to content

Commit

Permalink
Merge pull request #77 from Yoast/P3-519-email-feature-disappeared
Browse files Browse the repository at this point in the history
Adjust comment type checks for WP 5.5 and later.
  • Loading branch information
enricobattocchi authored Apr 20, 2021
2 parents b6431e0 + 94c3b55 commit ecfdfa9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 2 additions & 6 deletions inc/clean-emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private function add_comment_basics() {
* Adds the author line to the message.
*/
private function add_author_line() {
if ( $this->comment->comment_type === '' ) {
if ( $this->comment->comment_type === 'comment' ) {
/* translators: %1$s is replaced with the comment author's name, %2$s is replaced with the comment author's email */
$this->message .= \sprintf( \__( 'Author: %1$s (%2$s)', 'yoast-comment-hacks' ), \esc_html( $this->comment->comment_author ), '<a href="' . \esc_url( 'mailto:' . $this->comment->comment_author_email ) . '">' . \esc_html( $this->comment->comment_author_email ) . '</a>' ) . '<br />';
}
Expand All @@ -161,7 +161,7 @@ private function add_author_line() {
* Adds the content line to the message.
*/
private function add_content_line() {
if ( $this->comment->comment_type === '' ) {
if ( $this->comment->comment_type === 'comment' ) {
$this->message .= \__( 'Comment:', 'yoast-comment-hacks' );
}
else {
Expand Down Expand Up @@ -199,10 +199,6 @@ private function setup_data( $comment_id ) {
$this->comment_id = $comment_id;
$this->comment = \get_comment( $this->comment_id );
$this->post = \get_post( $this->comment->comment_post_ID );

if ( $this->comment->comment_type === 'comment' ) {
$this->comment->comment_type = '';
}
}

/**
Expand Down
10 changes: 7 additions & 3 deletions inc/email-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function admin_bar_comment_link() {

$current_user = \wp_get_current_user();

$results = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT comment_author_email FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_type = '' AND comment_approved = '1'", $post->ID ) );
$results = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT comment_author_email FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_type = 'comment' AND comment_approved = '1'", $post->ID ) );

if ( \count( $results ) === 0 ) {
return;
Expand All @@ -71,8 +71,12 @@ public function admin_bar_comment_link() {
// so browser extensions like the Google Mail one that change mailto: links still work.
echo '<a href="' . \esc_attr( $url ) . '" id="yst_email_commenters_alternate"></a><script>
function yst_email_commenters(e){
var ystEmailCommentersLink = document.getElementById( "yst_email_commenters_alternate" );
e.preventDefault();
window.location = jQuery(\'#yst_email_commenters_alternate\').attr(\'href\');
if ( ystEmailCommentersLink === null ) {
return;
}
window.location = ystEmailCommentersLink.getAttribute( "href" );
}
</script>';

Expand Down Expand Up @@ -118,7 +122,7 @@ public function wp_head_css() {
public function add_mailto_action_row( $actions ) {
global $comment;

if ( $comment->comment_type !== '' ) {
if ( $comment->comment_type !== 'comment' ) {
return $actions;
}

Expand Down

0 comments on commit ecfdfa9

Please sign in to comment.