| 1 |
<?php |
| 2 |
/** |
| 3 |
* Restriction utility functions for post types. |
| 4 |
* |
| 5 |
* @package ContentControl |
| 6 |
* @subpackage Functions |
| 7 |
* @copyright (c) 2023 Code Atlantic LLC |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace ContentControl; |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit; |
| 13 |
|
| 14 |
/** |
| 15 |
* Check if term has restrictions. |
| 16 |
* |
| 17 |
* @param int|null $term_id Term ID. |
| 18 |
* |
| 19 |
* @return bool |
| 20 |
* |
| 21 |
* @since 2.4.0 |
| 22 |
*/ |
| 23 |
function term_has_restrictions( $term_id = null ) { |
| 24 |
$overload_term = setup_term_globals( $term_id ); |
| 25 |
|
| 26 |
$has_restrictions = plugin( 'restrictions' )->has_applicable_restrictions( $term_id ); |
| 27 |
|
| 28 |
// Clear post if we overloaded it. |
| 29 |
if ( $overload_term ) { |
| 30 |
reset_term_globals(); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Filter whether term has restrictions. |
| 35 |
* |
| 36 |
* @param bool $has_restrictions Whether post has restrictions. |
| 37 |
* @param int|null $term_id Term ID. |
| 38 |
* |
| 39 |
* @return bool |
| 40 |
* |
| 41 |
* @since 2.0.0 |
| 42 |
*/ |
| 43 |
return (bool) apply_filters( 'content_control/term_has_restrictions', $has_restrictions, $term_id ); |
| 44 |
} |
| 45 |
|