diff --git a/docs/example.md b/docs/example.md index d7c760e..171519b 100644 --- a/docs/example.md +++ b/docs/example.md @@ -14,7 +14,7 @@ SupportsMultiple: false #} -
+{{ fields.testimonial }}
{{ fields.author }} diff --git a/docs/installation.md b/docs/installation.md index fcd2ddb..6872181 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -13,4 +13,8 @@ composer require "palmiak/timber-acf-wp-blocks" Next you can create your blocks in your theme in **views/blocks** folder (you can change it with a filter). +> **Note**: filenames should only contain lowercase alphanumeric characters and dashes, and must begin with a letter. + + + When you have your blocks ready the only thing left it to create a New group in ACF and select your block in **Show this field group if** selector. \ No newline at end of file diff --git a/timber-acf-wp-blocks.php b/timber-acf-wp-blocks.php index 480b996..1c50cf4 100644 --- a/timber-acf-wp-blocks.php +++ b/timber-acf-wp-blocks.php @@ -191,7 +191,7 @@ function () { */ function timber_blocks_callback( $block, $content = '', $is_preview = false, $post_id = 0 ) { // Set up the slug to be useful. - $context = Timber::get_context(); + $context = \Timber::get_context(); $slug = str_replace( 'acf/', '', $block['name'] ); $context['block'] = $block; @@ -199,11 +199,11 @@ function timber_blocks_callback( $block, $content = '', $is_preview = false, $po $context['slug'] = $slug; $context['is_preview'] = $is_preview; $context['fields'] = get_fields(); - $classes = array( - $slug, - isset( $block['className'] ) ? $block['className'] : null, - $is_preview ? 'is-preview' : null, - 'align' . $context['block']['align'], + $classes = array_merge( + array( $slug ), + isset( $block['className'] ) ? array( $block['className'] ) : array(), + $is_preview ? array( 'is-preview' ) : array(), + array( 'align' . $context['block']['align'] ), ); $context['classes'] = implode( ' ', $classes ); @@ -221,7 +221,7 @@ function timber_blocks_callback( $block, $content = '', $is_preview = false, $po $paths = timber_acf_path_render( $slug, $is_preview, $is_example ); - Timber::render( $paths, $context ); + \Timber::render( $paths, $context ); } /** @@ -258,7 +258,7 @@ function timber_blocks_subdirectories( $directories ) { $ret = array(); foreach ( $directories as $base_directory ) { - $template_directory = new \RecursiveDirectoryIterator( \locate_template( $base_directory ), FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_SELF ); + $template_directory = new \RecursiveDirectoryIterator( \locate_template( $base_directory ), \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_SELF ); if ( $template_directory ) { foreach ( $template_directory as $directory ) {