Giter Site home page Giter Site logo

Comments (5)

bobbingwide avatar bobbingwide commented on July 1, 2024

I need to undestand the documentation at https://www.advancedcustomfields.com/resources/blocks/

from acf-oik-blocks.

bobbingwide avatar bobbingwide commented on July 1, 2024

The first version of the block is now available.

It's dependent upon oik for the actual logic to generate the PayPal button.

Obviously it's also dependent upon ACF-Pro for the logic that

  • enables registration of the block
  • turns the ACF field group into the block's Settings panel

image

PayPal block settings for the Pay Now button.
image

ACF Pro fields group "PayPal".
image

from acf-oik-blocks.

bobbingwide avatar bobbingwide commented on July 1, 2024

Notes to self.

Question: How does ACF block rendering work?

  • acf_register_block_type() registers each block with the render_callback arg to set acf_render_block_callback.
  • acf_render_block_callback() sets values for $is_preview and $post_id then calls acf_rendered_block()
  • It uses output buffering to capture the output from the block's callback function or template which is invoked by acf_render_block().
  • acf_render_block() also enqueues assets defined for the block.

Question: How does the settings panel for ACF blocks work?

This is the magic that's hidden from the normal owner of the plugin since the invoking code is JavaScript that's been built from source code that's not part of the runtime package.

  • The Settings area is populated after an AJAX call with action acf/ajax/fetch-block from _acf-blocks.js.
  • This is implemented by acf_ajax_fetch_block() which uses a number of acf functions to render the fields associated with the block; acf_get_block_fields, acf_render_fields etc.
  • There are lots of filters that you can hook into, if you so wish.
  • The AJAX call returns the HTML in data.form
  • And ACF's react code shows these fields in the Settings area.

Since I don't have access to the source code I'm not going to investigate any further. Suffice it to say, ACF does quite a lot of work in some generic code that would otherwise have to be written in JavaScript for each block.

from acf-oik-blocks.

bobbingwide avatar bobbingwide commented on July 1, 2024

Donate button previewed in the block editor.

image

Donate button in Edit mode, basically the same as the Settings panel with a little extra styling.
image

from acf-oik-blocks.

bobbingwide avatar bobbingwide commented on July 1, 2024

Closing this for now. The block is dependent upon oik. I could improve it to remove the dependency but I've got other things to do.

from acf-oik-blocks.

Related Issues (2)

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.