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