wip: dynamic preview

This commit is contained in:
2025-09-24 08:46:02 -04:00
parent d553d8021d
commit 67118cd6c0
3 changed files with 34 additions and 0 deletions

View File

@@ -1,5 +1,35 @@
<?php <?php
// Override template file path for ACF previews
add_filter( 'acfe/flexible/render/template', 'ccat_acfe_flexible_render_template', 10, 4 );
function ccat_acfe_flexible_render_template( $file, $field, $layout, $is_preview ) {
if ( ! $is_preview ) {
return $file;
}
// Return relative path - ACF Extended Pro will use acfe_locate_file_path() to find it
return 'layouts/preview.php';
}
// Disable caching for preview requests
add_action( 'acfe/flexible/render/before_template', 'ccat_disable_cache_for_preview', 1, 3 );
function ccat_disable_cache_for_preview( $field, $layout, $is_preview ) {
if ( ! $is_preview ) {
return;
}
// Disable WordPress object cache for this request
wp_cache_flush();
// Send no-cache headers
nocache_headers();
// Disable ACF cache if function exists
if ( function_exists( 'acf_get_store' ) ) {
acf_get_store( 'fields' )->reset();
acf_get_store( 'field-groups' )->reset();
}
}
// Disable ACF / ACFE modules // Disable ACF / ACFE modules
add_action( 'acf/init', 'ccat_acf_init' ); add_action( 'acf/init', 'ccat_acf_init' );
function ccat_acf_init() { function ccat_acf_init() {

View File

@@ -0,0 +1 @@
<pre><?php var_dump( get_row( true ) ); ?></pre>

View File

@@ -0,0 +1,3 @@
export default defineEventHandler(() => {
return `<div>TODO: Preview from Nuxt API endpoint</div>`;
});