Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust comment type checks for WP 5.5 and later. #77

Merged
merged 2 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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