Created
December 27, 2013 05:59
-
-
Save zeropointdevelopment/8143140 to your computer and use it in GitHub Desktop.
[WordPress] Code from our blog post Stopping WordPress Media Attachment Comment Spamming - http://www.limecanvas.com/stopping-wordpress-media-attachment-comment-spamming/
This file contains 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
/** Stop comments being used on Media Files **/ | |
add_filter( 'comments_open', 'stopMediaComments', 10, 2 ); | |
function stopMediaComments( $open, $post_id ) { | |
$post = get_post( $post_id ); | |
if ( 'attachment' == $post->post_type ) | |
$open = false; | |
return $open; | |
} | |
/** This is used to get around non-native WordPress plugins **/ | |
add_filter('get_header', 'lcTurnCommentsOff'); | |
function lcTurnCommentsOff(){ | |
global $post; | |
if ( 'attachment' == $post->post_type ) | |
$post->comment_status="closed"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi