-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathapi-template.php
53 lines (48 loc) · 1.47 KB
/
api-template.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
51
52
53
<?php
/*
function: get_option_page_id
returns the ACF $post_id value to use
to get values for an options page
*/
if (!function_exists('get_option_page_id')) {
function get_option_page_id($slug) {
$post_id = 'options';
if (!function_exists('acf_get_options_pages')) {
// acf not installed, or function name changed
return $post_id;
}
$pages = acf_get_options_pages();
if (empty($pages)) {
return $post_id;
}
foreach ($pages as $page_slug => $page) {
if ($page_slug == $slug) {
$post_id = $page['post_id'];
// if parent slug not empty then break
if (!empty($page['parent_slug'])) {
break;
}
// if parent slug is empty and !redirect then break
if ($page['redirect']) {
if (isset($pages[$page['menu_slug']])) {
$post_id = $pages[$page['menu_slug']]['post_id'];
break;
}
}
}
} // end foreach $page
return $post_id;
} // end function get_option_page_id
} // end if !function
if (!function_exists('get_options_page_id')) {
function get_options_page_id($slug) {
return get_option_page_id($slug);
} // end function get_options_page_id
} // end if !function
if (!function_exists('get_option_page_id_filter')) {
function get_option_page_id_filter($post_id='', $slug='') {
return get_option_page_id($slug);
} // end function function get_option_page_id_filter
add_filter('acf/get_options_page_id', 'get_option_page_id_filter', 10, 2);
} // end if !function
?>