{"id":13579276,"url":"https://github.com/MWDelaney/sage-acf-wp-blocks","last_synced_at":"2025-04-05T20:33:36.273Z","repository":{"id":37431653,"uuid":"169429088","full_name":"MWDelaney/sage-acf-wp-blocks","owner":"MWDelaney","description":"Composer library for generating ACF Gutenberg blocks from templates. Intended for use with Roots/Sage (http://roots.io)","archived":false,"fork":false,"pushed_at":"2024-02-09T03:12:11.000Z","size":53,"stargazers_count":349,"open_issues_count":33,"forks_count":66,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-01T08:33:49.914Z","etag":null,"topics":["advanced-custom-fields","gutenberg","roots","sage-theme","wordpress"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MWDelaney.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-06T15:36:48.000Z","updated_at":"2025-03-21T10:39:29.000Z","dependencies_parsed_at":"2024-01-20T04:54:21.292Z","dependency_job_id":"814e00d1-db06-4cb6-928a-3ce521e4a507","html_url":"https://github.com/MWDelaney/sage-acf-wp-blocks","commit_stats":{"total_commits":54,"total_committers":13,"mean_commits":4.153846153846154,"dds":0.6296296296296297,"last_synced_commit":"50118a0a2d94ba2aa088f5a27d6f7dc818bc1245"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MWDelaney%2Fsage-acf-wp-blocks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MWDelaney%2Fsage-acf-wp-blocks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MWDelaney%2Fsage-acf-wp-blocks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MWDelaney%2Fsage-acf-wp-blocks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MWDelaney","download_url":"https://codeload.github.com/MWDelaney/sage-acf-wp-blocks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399874,"owners_count":20932876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["advanced-custom-fields","gutenberg","roots","sage-theme","wordpress"],"created_at":"2024-08-01T15:01:37.974Z","updated_at":"2025-04-05T20:33:31.258Z","avatar_url":"https://github.com/MWDelaney.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Sage ACF Gutenberg Blocks\nGenerate ACF Gutenberg blocks just by adding templates to your Sage theme. This package is based heavily on [this article](https://medium.com/nicooprat/acf-blocks-avec-gutenberg-et-sage-d8c20dab6270) by [nicoprat](https://github.com/nicooprat).\n\n## Installation\nRun the following in your Sage (v9 or 10) based theme directory:\n```sh\ncomposer require \"mwdelaney/sage-acf-gutenberg-blocks\"\n```\n\n## Creating blocks\nAdd blade templates to `views/blocks` which get and use ACF data. Each template requires a comment block with some data in it:\n```blade\n{{--\n  Title:\n  Description:\n  Category:\n  Icon:\n  Keywords:\n  Mode:\n  Align:\n  PostTypes:\n  SupportsAlign:\n  SupportsMode:\n  SupportsMultiple:\n  EnqueueStyle:\n  EnqueueScript:\n  EnqueueAssets:\n--}}\n```\n\n### Example block template\n\n```blade\n{{--\n  Title: Testimonial\n  Description: Customer testimonial\n  Category: formatting\n  Icon: admin-comments\n  Keywords: testimonial quote\n  Mode: edit\n  Align: left\n  PostTypes: page post\n  SupportsAlign: left right\n  SupportsMode: false\n  SupportsMultiple: false\n  EnqueueStyle: styles/style.css\n  EnqueueScript: scripts/script.js\n  EnqueueAssets: path/to/asset\n--}}\n\n\u003cblockquote data-{{ $block['id'] }} class=\"{{ $block['classes'] }}\"\u003e\n    \u003cp\u003e{{ get_field('testimonial') }}\u003c/p\u003e\n    \u003ccite\u003e\n      \u003cspan\u003e{{ get_field('author') }}\u003c/span\u003e\n    \u003c/cite\u003e\n\u003c/blockquote\u003e\n\n\u003cstyle type=\"text/css\"\u003e\n  [data-{{$block['id']}}] {\n    background: {{ get_field('background_color') }};\n    color: {{ get_field('text_color') }};\n  }\n\u003c/style\u003e\n```\n\n## Data Options\n\nThe options in the file header map to options in the [`acf_register_block_type`  function](https://www.advancedcustomfields.com/resources/acf_register_block_type/).\n\n| Field              | Description                                      | Values     | Notes |\n| ------------------ | ------------------------------------------------ | ---------- | ----  |\n| `Title`            | Title of the block in the gutenberg editor | i.e. `Testimonial` | _required_ |\n| `Description`      | Description of the block in the gutenberg editor | i.e. `My testimonial block` | _optional_ |\n| `Category`         | Category to store the block in. Use these values or [register your own custom block categories](https://wordpress.org/gutenberg/handbook/extensibility/extending-blocks/#managing-block-categories) | `common`, `formatting`, `layout`, `widgets`, `embed` | _required_ |\n| `Icon`             | An icon property can be specified to make it easier to identify a block. Uses [dashicons](https://developer.wordpress.org/resource/dashicons/) | i.e. `book-alt` | _optional_ |\n| `Keywords`         | An array of search terms to help user discover the block while searching. Sepearate values with a space. | i.e. `quote mention cite` | _optional_ |\n| `Mode`             | The display mode for your block. auto: Preview is shown by default but changes to edit form when block is selected. preview: Preview is always shown. Edit form appears in sidebar when block is selected. edit: Edit form is always shown. | `auto`, `preview` or `edit` |_optional_ (defaults to `preview`) |\n| `Align`            | The default block alignment. | `left center right wide full` |_optional_ (defaults to empty string)\n| `PostTypes`        | An array of post types to restrict this block type to. Sepearate values with a space. | i.e. `post page` |\n| `SupportsAlign`    | This property adds block controls which allow the user to change the block’s alignment. Set to true to show  all alignments, false to hide the alignment toolbar. Set to an array (strings separated by spaces) of specific alignment names to customize the toolbar. | (boolean) `true`, `false`\u003cbr\u003e or (array) `left center right wide full` | _optional_ (defaults to true) |\n| `SupportsMode`     | This property allows the user to toggle between edit and preview modes via a button. | `true`  or `false` |_optional_ (defaults to `true`) |\n| `SupportsMultiple` | This property allows the block to be added multiple times. | `true`  or `false` |_optional_ (defaults to `true`) |\n| `SupportsInnerBlocks` | This property allows the block to support the nesting of other blocks within it. | `true`  or `false` |_optional_ (defaults to `false`) |\n| `SupportsAlignText` | This property adds an alignment toolbar button similar to that seen when editing a paragraph of text. | `true`  or `false` |_optional_ (defaults to `false`) |\n| `SupportsAlignContent` | This property adds an alignment toolbar button similar to that seen when editing a core \"Cover block\" | `true`  or `false` |_optional_ (defaults to `false`) |\n\n## Creating ACF fields\nOnce a block is created you'll be able to assign ACF fields to it using the standard Custom Fields interface in WordPress. We recommend using [sage-advanced-custom-fields](https://github.com/MWDelaney/sage-advanced-custom-fields) to keep your ACF fields in version control with Sage.\n\n## Filter block data\nBlock data can be altered via the 'sage/blocks/[block-name]/data' filter. For example, if your block template is called `my-block.blade.php`, you can alter the data this way:\n\n```php\nadd_filter('sage/blocks/my-block/data', function ($block) { // Do your thing here. });\n```\n\n## Filter template folders\nBy default all your template files in `views/blocks` will be loaded. You can use the templates filter to add more folders if you wish. See an example below of how to add your own folders.\n\n```php\nadd_filter('sage-acf-gutenberg-blocks-templates', function ($folders) { \n    $folders[] = 'views/your-folder'; // Adds your folder\n    return $folders;\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMWDelaney%2Fsage-acf-wp-blocks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMWDelaney%2Fsage-acf-wp-blocks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMWDelaney%2Fsage-acf-wp-blocks/lists"}