Writing a plugin that includes Blocks for Sage 10 via Log1x/acf-composer

Trying to reduce the amount of blocks that are created across all of our Sage 10 themes each and every build, and thought it seemed like the perfect use case for a plugin.

We currently have an Accordion block across ten themes all being worked on at the same time, and will likely include it in many more, as well as a dozen other blocks.

In Sage 10 we have for example the following 2 files that are working just fine.


Then I created a new plugin called test-tailwind-blocks and inside of that have a test-tailwind-blocks.php file. I copied over both these block files and their directories so that they now live in the plugin instead of the theme.

Ran composer require log1x/acf-composer so that this also exists inside of the plugin.

For the plugin files contents there’s


 * Plugin Name:        Test Tailwind Blocks
 * Plugin URI:         https://example.com
 * Description:        A collection of Tailwind Blocks.
 * Version:            0.0.1
 * Author:             example
 * Author URI:         https://example.com/
 * Primary Branch:     main
 * License:            MIT License
 * License URI:        https://opensource.org/licenses/MIT

require_once plugin_dir_path(__FILE__) . 'vendor/autoload.php';

require_once plugin_dir_path(__FILE__) . 'app/Blocks/Accordion.php';

This allows the site to still load, and allows the plugin to be activated, but it appears that it does not actually activate the block anywhere as it’s not visible in the editor.

I’m guessing there’s some small part that is missing. Moving these 2 directories/files back over to Sage 10 makes them show up just fine, but we’re trying to make these reusable before we start building all of our sites on Sage 10. Not sure if I’m actually going in the correct direction with this. Followed a few guide for building a plugin that added blocks but none of them used Sage 10 or the package from @Log1x

This topic was automatically closed after 42 days. New replies are no longer allowed.