Home/ Documentation/ WordPress/ Blocks/ Generated Code and Files

Generated Code and Files

Blocks are just a part of WordPress files that are exported by Pinegrow. Either a whole theme or a plugin are generated, in dependance on the project settings. That said, we will focus on Blocks in this guide. Please note, that you don’t have to do anything special with the above mentioned files, or understand

Blocks are just a part of WordPress files that are exported by Pinegrow.

Either a whole theme or a plugin are generated, in dependance on the project settings.

That said, we will focus on Blocks in this guide.

Please note, that you don’t have to do anything special with the above mentioned files, or understand their content. Still, it is a good idea to know how the exported blocks are structured.

Each time we export the project, or save the page that contains blocks, Pinegrow will create the following files:

blocks/<block_id>/<block_id>_register.php contains the PHP code that registers the block on the server.

blocks/<block_id>/<block_id>.js contains the browser-side JavaScript code that implements the block in the WordPress block editor. The code is exported in a plain JavaScript React code that doesn’t need any further compilation to run. The code is nor pretty and is not intended to be edited by hand.

blocks/<block_id>/<block_id>.php is additionally generated for dynamic PHP blocks. It contains the PHP code that renders the block.

Pinegrow adds three helper files:

inc/wp_pg_helpers.php contains helper functions for registering blocks and working with attributes of dynamic PHP blocks.

blocks/pg-blocks-controls.js and blocks/pg-blocks-controls.js implement controls for image, link and posts block attributes.



Last updated on October 29, 2021 at 5:28 am


Print this article