MWDelaney / sage-acf-wp-blocks

Composer library for generating ACF Gutenberg blocks from templates. Intended for use with Roots/Sage (http://roots.io)
346 stars 66 forks source link

Custom Blocks disappear with update to latest ACF #14

Closed SamirJoza closed 5 years ago

SamirJoza commented 5 years ago

Hi, maybe it's just me, since I am fairly new to Sage, but my custom blocks used to work with ACF 5.8 latest RC, but once I updated ACF to the latest production version, everything literally disappeared. And is no longer working. this is what I have in my /app/filters.php add_filter( 'block_categories', function( $categories, $post ) { return array_merge( $categories, array( array( 'slug' => 'xsp', 'title' => 'Special Blocks', ), ) ); }, 10, 2 ); and then in /resources/views/blocks/newsletter-article.blade.php `{{-- Title: Newsletter Article Description: Newsletter Article Category: xsp Icon: media-document Keywords: Mode: edit Align: left SupportsMode: false SupportsMultiple: false PostTypes: page --}}

<article data-{{$block['id']}} class="{{ $block['classes'] }} summary">

{!!NewsletterArticle::Article()['title']!!}

{!!NewsletterArticle::Article()['img']!!}

{!!NewsletterArticle::Article()['content']!!}

Click to read more


` As I said, it used to work flawlessly, but with the upgrade to the latest ACF version, all no working. Even if I change Category to 'formatting' the block is not being made available.

Any help is greatly appreciated.

jnaklaas commented 5 years ago

I can confirm this issue. Except that the plugin does work with the latest ACF PRO production version. It does NOT work however with the free ACF production versions (5.8.0 nor 5.8.1)

nahojj commented 5 years ago

Same for me, I'm running ACF 5.8.1 and having the same problem.

nahojj commented 5 years ago

It seems that the plugin is trying to call "acf_register_block()" which is the old function in ACF to register blocks, the new one is called "acf_register_block_type()".. Please, can you fix this?

nahojj commented 5 years ago

I've removed "className" on line 104 and now it works for me.

jnaklaas commented 5 years ago

Yes you should change line 104 to this:

$class_name = (empty($block['className'])) ? false : $block['className'] . ',';
$block['classes'] = implode(' ', [$block['slug'], $class_name . 'align'.$block['align']]);

But this is a different issue then the OP. After fixing the plugin still only works in ACF PRO, not the free ACF. May I assume you' running ACF PRO as well @nahojj ?

nahojj commented 5 years ago

@jnaklaas I do use ACF PRO as well! I don't think the block registration for ACF is free :)

nahojj commented 5 years ago

Please read: https://www.advancedcustomfields.com/pro/

jnaklaas commented 5 years ago

I see :) In that case, as far as I'm concerned this issue's solved.

MWDelaney commented 5 years ago

Closing this since it seems to be solved. I can reopen if anyone using PRO finds this issue as well.

da-kicks-87 commented 3 years ago

I am using the ACF Pro version and I can't register a new block categories.

In filters.php

add_filter( 'block_categories', function ($categories, $post ) {

if ( $post->post_type !== 'post' ) { return $categories; } return array_merge( $categories, array( array( 'slug' => 'acf-blocks', 'title' => __( 'ACF Blocks', 'acf-blocks' ), 'icon' => 'wordpress', ), ) ); }, 10, 2);

Then on my block template: {{-- Title: Section Cards Description: Section of a page with cards. Category: acf-blocks Icon: admin-comments Keywords: section, cards Mode: edit Align: full PostTypes: page post SupportsAlign: false SupportsMode: true SupportsMultiple: true SupportsInnerBlocks: true EnqueueAssets: path/to/asset --}}