Blocks
1 week ago
Datastore
1 month ago
Meta
1 year ago
abilities
1 week ago
admin
1 week ago
ajax
1 month ago
api
2 days ago
fields
2 days ago
forms
2 days ago
legacy
1 year ago
locations
1 year ago
post-types
2 months ago
rest-api
1 week ago
walkers
1 year ago
acf-bidirectional-functions.php
1 year ago
acf-field-functions.php
2 months ago
acf-field-group-functions.php
7 months ago
acf-form-functions.php
1 year ago
acf-helper-functions.php
1 year ago
acf-hook-functions.php
1 year ago
acf-input-functions.php
7 months ago
acf-internal-post-type-functions.php
7 months ago
acf-meta-functions.php
3 weeks ago
acf-post-functions.php
1 year ago
acf-post-type-functions.php
1 year ago
acf-taxonomy-functions.php
1 year ago
acf-user-functions.php
1 week ago
acf-utility-functions.php
1 year ago
acf-value-functions.php
1 year ago
acf-wp-functions.php
2 days ago
assets.php
1 week ago
blocks-auto-inline-editing.php
2 months ago
blocks.php
3 weeks ago
class-acf-data.php
10 months ago
class-acf-internal-post-type.php
1 week ago
class-acf-options-page.php
1 year ago
class-acf-site-health.php
3 months ago
class-scf-json-schema-validator.php
6 months ago
class-scf-schema-builder.php
2 months ago
compatibility.php
1 year ago
datastore.php
1 month ago
deprecated.php
1 year ago
fields.php
10 months ago
index.php
1 year ago
l10n.php
1 year ago
local-fields.php
1 year ago
local-json.php
1 month ago
local-meta.php
1 year ago
locations.php
1 year ago
loop.php
10 months ago
media.php
1 year ago
rest-api.php
10 months ago
revisions.php
1 month ago
scf-ui-options-page-functions.php
1 year ago
third-party.php
7 months ago
upgrades.php
3 weeks ago
validation.php
10 months ago
wpml.php
1 year ago
acf-post-functions.php
40 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Returns available templates for each post type. |
| 5 | * |
| 6 | * @date 29/8/17 |
| 7 | * @since ACF 5.6.2 |
| 8 | * |
| 9 | * @return array |
| 10 | */ |
| 11 | function acf_get_post_templates() { |
| 12 | |
| 13 | // Check store. |
| 14 | $cache = acf_get_data( 'post_templates' ); |
| 15 | if ( $cache !== null ) { |
| 16 | return $cache; |
| 17 | } |
| 18 | |
| 19 | // Initialize templates with default placeholder for pages. |
| 20 | $post_templates = array(); |
| 21 | $post_templates['page'] = array(); |
| 22 | |
| 23 | // Loop over post types and append their templates. |
| 24 | if ( method_exists( 'WP_Theme', 'get_page_templates' ) ) { |
| 25 | $post_types = get_post_types(); |
| 26 | foreach ( $post_types as $post_type ) { |
| 27 | $templates = wp_get_theme()->get_page_templates( null, $post_type ); |
| 28 | if ( $templates ) { |
| 29 | $post_templates[ $post_type ] = $templates; |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | // Update store. |
| 35 | acf_set_data( 'post_templates', $post_templates ); |
| 36 | |
| 37 | // Return templates. |
| 38 | return $post_templates; |
| 39 | } |
| 40 |