Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[task] added filter to allow change of fileidentifier for preview and… #29

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions timber-acf-wp-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,22 +236,25 @@ function timber_blocks_callback( $block, $content = '', $is_preview = false, $po
* @param bool $is_preview Checks if preview.
* @param bool $is_example Checks if example.
*/
function timber_acf_path_render( $slug, $is_preview, $is_example ) {
$directories = timber_block_directory_getter();
function timber_acf_path_render($slug, $is_preview, $is_example) {
$directories = timber_block_directory_getter();

$ret = array();
$ret = [];

foreach ( $directories as $directory ) {
if ( $is_example ) {
$ret[] = $directory . "/{$slug}-example.twig";
}
if ( $is_preview ) {
$ret[] = $directory . "/{$slug}-preview.twig";
$exampleIdentifier = apply_filters('timber/acf-gutenberg-blocks-example-identifier', '-example');
$previewIdentifier = apply_filters('timber/acf-gutenberg-blocks-preview-identifier', '-preview');

foreach ($directories as $directory) {
if ($is_example) {
$ret[] = $directory . "/{$slug}{$exampleIdentifier}.twig";
}
if ($is_preview) {
$ret[] = $directory . "/{$slug}{$previewIdentifier}.twig";
}
$ret[] = $directory . "/{$slug}.twig";
}
$ret[] = $directory . "/{$slug}.twig";
}

return $ret;
return $ret;
}

/**
Expand Down