bobbingwide / acf-oik-blocks Goto Github PK
View Code? Open in Web Editor NEWExperimenting with ACF blocks for oik
Experimenting with ACF blocks for oik
At the WordPress Cambridge Meetup someone asked about developing blocks using PHP. I said that there are some solutions about. The one I'd tried was ACF-Pro, but it was a long time ago and I didn't get very far. We agreed that it would be a good subject for future meetups. I have a documented requirement to develop a block version of the PayPal shortcode. bobbingwide/oik#184
I could just go ahead and develop a version with JavaScript, bit it also makes sense to attempt to develop it using ACF-Pro's PHP based block solution.
While this will give me more experience with ACF-Pro, it's unlikely that I'll make ACF-Pro a dependency on oik.
So it's just a short term distraction for educational purposes.
[paypal]
shortcode logic from oikI've had an ACF-Pro licence since 10 November 2019. Other than what I'm writing up here I've done nothing with it since I first got it. My first attempt to do something was to create a block called block-count
to display the Block Count.
This is how it works.
acf/init
action it registers the Block Count block using acf_register_block_type()
.acf_oik_blocks_callback()
, echos the outputget_field()
for a field called _block_count
.s.b/wordpress
I wrote some shortcodes and blocks to test this field for the oik-magnetic-poetry plugin.Here's the HTML code for some of the oik-magnetic-poetry post
https://s.b/wordpress/oik-plugins/magnetic-poetry/
<!-- wp:paragraph -->
<p>Block count: [acf field=_block_count]</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>[bw_fields fields=_block_count ]</p>
<!-- /wp:paragraph -->
<!-- wp:acf/block-count {"id":"block_5dc84573ff9e5","name":"acf/block-count","data":{"_block_count":"4","__block_count":"field_5dc8302fb9fa3"},"align":"","mode":"preview"} /-->
[acf]
shortcode is provided by ACF https://www.advancedcustomfields.com/resources/shortcode/_block_count
field is also registered using oik-fields[bw_fields]
.acf/
prefix has been added automatically.On the front end it displays the same output for each of the 3 blocks.
Block count: 42
where 42 is the number entered in the seamless metabox
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.