-
Notifications
You must be signed in to change notification settings - Fork 0
/
acf-supports-location.php
50 lines (36 loc) · 1.21 KB
/
acf-supports-location.php
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
<?php
/*
Plugin Name: ACF Supports Location
Plugin URI: https://github.com/theideabureau/acf-supports-location
Version: 0.1
Author: The Idea Bureau
Author URI: http://theideabureau.co
Description: Adds a new location for Advanced Custom Fields for post type support.
Text Domain: acf-supports-location
License: GPLv3
*/
add_filter('acf/location/rule_types', function($choices) {
$choices['Supports']['supports'] = 'Post Type Support';
return $choices;
});
add_filter('acf/location/rule_values/supports', function($choices) {
$choices = array_merge($choices, array(
'title' => 'Title',
'editor' => 'Editor',
'author' => 'Author',
'thumbnail' => 'Thumbnail',
'excerpt' => 'Excerpt',
'trackbacks' => 'Trackbacks',
'custom-fields' => 'Custom Fields',
'comments' => 'Comments',
'revisions' => 'Revisions',
'page-attributes' => 'Page Attributes',
'post-formats' => 'Post Formats'
));
return $choices;
});
add_filter('acf/location/rule_match/supports', function($match, $rule, $options) {
$supported = post_type_supports(get_post_type(), $rule['value']);
$required = $rule['operator'] === '==';
return $supported === $required;
}, 10, 3);