Skip to content

Commit

Permalink
Add report spam link
Browse files Browse the repository at this point in the history
Add report spam action link to spam list (#73)
  • Loading branch information
Zodiac1978 committed Aug 13, 2020
1 parent 0c9446b commit eceb64e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
12 changes: 10 additions & 2 deletions antispam_bee.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,22 @@ public static function init() {
'print_column_styles',
)
);

add_filter(
'manage_edit-comments_sortable_columns',
array(
'Antispam_Bee_Columns',
'register_sortable_columns',
)
);
add_filter(
'comment_row_actions',
array(
'Antispam_Bee_Columns',
'add_report_comment_action_link',
),
10,
2
);
add_action(
'pre_get_comments',
array(
Expand Down Expand Up @@ -295,7 +303,6 @@ public static function init() {
'populate_post_id',
)
);

add_action(
'template_redirect',
array(
Expand Down Expand Up @@ -2796,6 +2803,7 @@ private static function db_version_is_current() {
return $current_version === self::$db_version;

}

}


Expand Down
34 changes: 34 additions & 0 deletions inc/columns.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,38 @@ public static function print_column_styles() {
</style>
<?php
}

/**
* Add comment action link to report spam to ASB
*
* @since 2.9.3
*
* @param array $actions Array of actions.
* @param comment $comment Comment object.
*/
public static function add_report_comment_action_link( $actions, $comment ) {

// URLencode comment data.
$name = rawurlencode( $comment->comment_author );
$email = rawurlencode( $comment->comment_author_email );
$ip = rawurlencode( $comment->comment_author_IP );
$host = rawurlencode( gethostbyaddr( $ip ) );
$url = rawurlencode( $comment->comment_author_url );
$content = rawurlencode( $comment->comment_content );
$agent = rawurlencode( $comment->comment_agent );

// Build action link.
$target = ' target="_blank" ';
$rel = ' rel="noopener noreferrer" ';
$href = 'href="https://docs.google.com/forms/d/e/1FAIpQLSeQlKVZZYsF1qkKz7U78B2wy_6s6I7aNSdQc-DGpjeqWx70-A/viewform?c=0&w=1&entry.437446945=' . $name . '&entry.462884433=' . $ip . '&entry.1346967038=' . $host . '&entry.121560485=' . $email . '&entry.1210529682=' . $url . '&entry.1837399577=' . $content . '&entry.372858475=' . $agent . '" ';

$action = '';
$action .= "<a $target $href $rel>";
$action .= __( 'Report to Antispam Bee', 'antispam-bee' );
$action .= '</a>';

$actions['report_spam trash'] = $action;

return $actions;
}
}

0 comments on commit eceb64e

Please sign in to comment.