PluginProbe
Advanced Custom Fields (ACF®) / 6.1.0
Advanced Custom Fields (ACF®) v6.1.0
6.8.9 6.8.8 6.8.7 6.8.6 6.8.5 6.8.4 6.8.3 6.8.2 6.8.1 5.8.5 5.8.6 5.8.7 5.8.8 5.8.9 5.9.0 5.9.1 5.9.2 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 5.9.9 6.0.0 All 230 releases
advanced-custom-fields / includes / acf-post-functions.php
acf-post-functions.php
41 lines 889 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Returns available templates for each post type.
5 *
6 * @date 29/8/17
7 * @since 5.6.2
8 *
9 * @param void
10 * @return array
11 */
12 function acf_get_post_templates() {
13
14 // Check store.
15 $cache = acf_get_data( 'post_templates' );
16 if ( $cache !== null ) {
17 return $cache;
18 }
19
20 // Initialize templates with default placeholder for pages.
21 $post_templates = array();
22 $post_templates['page'] = array();
23
24 // Loop over post types and append their templates.
25 if ( method_exists( 'WP_Theme', 'get_page_templates' ) ) {
26 $post_types = get_post_types();
27 foreach ( $post_types as $post_type ) {
28 $templates = wp_get_theme()->get_page_templates( null, $post_type );
29 if ( $templates ) {
30 $post_templates[ $post_type ] = $templates;
31 }
32 }
33 }
34
35 // Update store.
36 acf_set_data( 'post_templates', $post_templates );
37
38 // Return templates.
39 return $post_templates;
40 }
41