Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wpse15750_comment_check( $id ){
- if( get_post_type( $id ) == 'attachment' )
- exit;
- }
- add_action( 'pre_comment_on_post', 'wpse15750_comment_check' );
- function wpse15750_comments_closed( $open, $id ){
- if( get_post_type( $id ) == 'attachment' )
- return false;
- return $open;
- }
- add_action( 'pre_comment_on_post', 'wpse15750_comments_closed', 10, 2 );
- global $wpdb;
- $wpdb->update( $wpdb->posts, array( 'comment_status' => 'closed' ), array( 'post_type' => 'attachments', 'comment_status' => 'open' ) );
- function wpse15750_no_attachment_comments( $data ){
- if( $data['post_type'] == 'attachment' )
- $data['comment_status'] = 'closed';
- return $data;
- }
- add_filter( 'wp_insert_post_data', 'wpse15750_no_attachment_comments' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement