Log1x / acf-composer

Compose ACF Fields, Blocks, Widgets, and Option Pages with ACF Builder on Sage 10.
https://github.com/Log1x/acf-composer
MIT License
398 stars 53 forks source link

block.json - textdomain missing #233

Closed mLicorn closed 3 months ago

mLicorn commented 3 months ago

Hello,

I noticed that there was no textdomain field in the block.json generated by the acf:cache command. This field is required to translate the block title and description. Below is what I've set up to add the field if you'd like to test.

namespace App\Blocks;

use Log1x\AcfComposer\Block;
use Log1x\AcfComposer\AcfComposer;
use Illuminate\Support\Collection;

class MyBlock extends Block
{
    public string $textdomain = 'theme-domain';

    public function __construct(AcfComposer $composer)
    {
        parent::__construct($composer);

        $this->name = _x('My Block Title', 'block title', 'theme-domain');
        $this->description = _x('My Block Description', 'block description', 'theme-domain');
    }

    public function settings(): Collection
    {
        return parent::settings()->put('textdomain', $this->textdomain);
    }
}
wp acorn acf:cache