Git Product home page Git Product logo

Comments (5)

Log1x avatar Log1x commented on August 26, 2024 1

You mentioned not using this feature. How are you adding custom blocks to Sage that aren't ACF based?

I only use ACF for blocks. I've written a few native blocks in the past – they are great, but once ACF got InnerBlock support, I was sold as I'm much more comfortable with PHP in the end.

When I was using native blocks I used the same approach as Poet though:

add_action('init', function () {
    return collect([
        'block/product',
    ])->each(function ($block) {
        register_block_type($block, [
            'render_callback' => function ($data, $content) use ($block) {
                return view(resource_path('views/blocks/' . Str::after($block, '/') . '.blade.php'), [
                    'data' => (object) $data,
                    'content' => ! empty(wp_strip_all_tags($content, true)) ? $content : null
                ]);
            }
        ]);
    });
}, 20);

so I'm definitely confused on what could be wrong.

from poet.

Log1x avatar Log1x commented on August 26, 2024

Hmm. I don't use this feature so I didn't know anything was wrong with it.

I'm not exactly sure though. I tried using register_block_type() outside of Poet and still can't seem to get a block to register in the editor.

I'm seeing:

^ WP_Block_Type {#2372 ▼
  +api_version: 1
  +name: "app/example"
  +title: ""
  +category: null
  +parent: null
  +ancestor: null
  +icon: null
  +description: ""
  +keywords: []
  +textdomain: null
  +styles: []
  +variations: []
  +supports: null
  +example: null
  +render_callback: Closure() {#2369}
  +attributes: array:1 [▶]
  +uses_context: []
  +provides_context: null
  +editor_script_handles: []
  +script_handles: []
  +view_script_handles: []
  +editor_style_handles: []
  +style_handles: []
  -deprecated_properties: array:5 [▶]
}

being returned when registering. I figured maybe it needed a title, category, etc. set on it, but even when I do that, I'm getting nothing.

I checked wp.blocks.getBlockTypes(); in console and it is not showing up there, either.

I'll have to tinker more but not sure if the usage of this function was updated in core at some point or if I'm going crazy. :)

from poet.

unscripted avatar unscripted commented on August 26, 2024

Thanks for taking a look. I thought I was going crazy too. haha

You mentioned not using this feature. How are you adding custom blocks to Sage that aren't ACF based?

from poet.

braco avatar braco commented on August 26, 2024

think I'm having this problem too. Is this feature broken in poet?

from poet.

Log1x avatar Log1x commented on August 26, 2024

Have you registered your block in the editor after registering the block with Poet?

import { __ } from '@wordpress/i18n';
import { registerBlockType } from '@wordpress/blocks';
import { InnerBlocks } from '@wordpress/block-editor';

import { edit } from './edit';

registerBlockType('block/example', {
  title: __('Example', 'app'),
  description: 'An example block.',
  category: 'common',
  icon: 'star-filled',
  attributes: {
    title: {
      type: 'string'
    },
  },
  edit,
  save: props => <InnerBlocks.Content />
});

from poet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.