Post.php
2.17 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace ACA\ACF\FieldGroup\Location;
use ACA\ACF\FieldGroup;
class Post implements FieldGroup\Query {
const POST = 'post';
const PAGE = 'page';
/**
* @var string
*/
private $post_type;
public function __construct( $post_type ) {
$this->post_type = $post_type;
}
public function get_groups() {
add_filter( 'acf/location/rule_match/user_type', '__return_true', 16 );
add_filter( 'acf/location/rule_match/page_type', '__return_true', 16 );
switch ( $this->post_type ) {
case self::POST :
add_filter( 'acf/location/rule_match/post_format', '__return_true', 16 );
break;
case self::PAGE :
add_filter( 'acf/location/rule_match/page', '__return_true', 16 );
add_filter( 'acf/location/rule_match/page_parent', '__return_true', 16 );
add_filter( 'acf/location/rule_match/page_template', '__return_true', 16 );
add_filter( 'acf/location/rule_match/post_template', '__return_true', 16 );
break;
}
add_filter( 'acf/location/rule_match/post', '__return_true', 16 );
add_filter( 'acf/location/rule_match/post_category', '__return_true', 16 );
add_filter( 'acf/location/rule_match/post_status', '__return_true', 16 );
add_filter( 'acf/location/rule_match/post_taxonomy', '__return_true', 16 );
$groups = acf_get_field_groups( [ 'post_type' => $this->post_type ] );
remove_filter( 'acf/location/rule_match/user_type', '__return_true', 16 );
remove_filter( 'acf/location/rule_match/page_type', '__return_true', 16 );
remove_filter( 'acf/location/rule_match/post_format', '__return_true', 16 );
remove_filter( 'acf/location/rule_match/page', '__return_true', 16 );
remove_filter( 'acf/location/rule_match/page_parent', '__return_true', 16 );
remove_filter( 'acf/location/rule_match/page_template', '__return_true', 16 );
remove_filter( 'acf/location/rule_match/post', '__return_true', 16 );
remove_filter( 'acf/location/rule_match/post_category', '__return_true', 16 );
remove_filter( 'acf/location/rule_match/post_status', '__return_true', 16 );
remove_filter( 'acf/location/rule_match/post_taxonomy', '__return_true', 16 );
remove_filter( 'acf/location/rule_match/post_template', '__return_true', 16 );
return $groups;
}
}