Last active
August 29, 2015 14:24
-
-
Save danielpowney/2b1b9ff0a3a11afce54e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
/** | |
* Sets post_tag taxonomy terms that are allowed to do wp comment integration | |
* | |
* @param boolean $can_apply_filter | |
* @param string $filter_name | |
* @param string $value | |
* @param int $post_id | |
* @return $can_apply_filter | |
*/ | |
function mrp_check_post_tag_wp_comment_integration( $can_apply_wp_comment_integration, $post_id, $type ) { | |
if ( $can_apply_wp_comment_integration ) { | |
$found = false; | |
$terms = get_the_terms( $post_id, 'post_tag' ); // << add your taxonomy here in her | |
if ( $terms && is_array( $terms ) ) { | |
foreach ( $terms as $term ) { | |
if ( in_array( $term->name , array( 'term1', 'term2' ) ) ) { // << add your term names here | |
$found = true; | |
break; | |
} | |
} | |
} | |
if ( ! $found ) { | |
$can_apply_wp_comment_integration = false; | |
} | |
} | |
return $can_apply_wp_comment_integration; | |
} | |
add_filter( 'mrp_can_apply_wp_comment_integration', 'mrp_check_post_tag_wp_comment_integration', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment