{"id":16000909,"url":"https://github.com/bacoords/block-settings","last_synced_at":"2025-03-17T21:31:11.182Z","repository":{"id":244282502,"uuid":"814790509","full_name":"bacoords/block-settings","owner":"bacoords","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-26T17:59:26.000Z","size":198,"stargazers_count":15,"open_issues_count":6,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-10T22:40:58.818Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/bacoords.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":"2024-06-13T17:57:22.000Z","updated_at":"2025-02-08T04:40:23.000Z","dependencies_parsed_at":"2024-06-13T20:55:58.345Z","dependency_job_id":"5bd7d04c-cfb7-4bd8-80f6-35b55b1cdaf4","html_url":"https://github.com/bacoords/block-settings","commit_stats":null,"previous_names":["bacoords/block-settings"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bacoords%2Fblock-settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bacoords%2Fblock-settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bacoords%2Fblock-settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bacoords%2Fblock-settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bacoords","download_url":"https://codeload.github.com/bacoords/block-settings/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243885930,"owners_count":20363644,"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":[],"created_at":"2024-10-08T09:20:58.584Z","updated_at":"2025-03-17T21:31:10.920Z","avatar_url":"https://github.com/bacoords.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Block Settings\n\nProof of concept of a `register_block_setting()` function to quickly add settings fields to blocks with just PHP.\n\n## Usage\n\n```php\n\t// Register a \"Button Style\" setting for the Button block.\n\twpdev_register_block_setting(\n\t\tarray(\n\t\t\t'attribute'  =\u003e 'prefixButtonStyle',\n\t\t\t'blockTypes' =\u003e array( 'core/button' ),\n\t\t\t'label'      =\u003e 'Select Button Style',\n\t\t\t'multiple'   =\u003e false,\n\t\t\t'options'    =\u003e array(\n\t\t\t\tarray(\n\t\t\t\t\t'value' =\u003e '',\n\t\t\t\t\t'label' =\u003e 'Default',\n\t\t\t\t),\n\t\t\t\tarray(\n\t\t\t\t\t'value' =\u003e 'block-style-outline',\n\t\t\t\t\t'label' =\u003e 'Outline',\n\t\t\t\t),\n\t\t\t\tarray(\n\t\t\t\t\t'value' =\u003e 'block-style-solid',\n\t\t\t\t\t'label' =\u003e 'Solid',\n\t\t\t\t),\n\t\t\t),\n\t\t\t'help'       =\u003e 'Select a style for the button.',\n\t\t),\n\t);\n```\n\u003cimg width=\"896\" alt=\"Xnapper-2024-06-13-15 23 31\" src=\"https://github.com/bacoords/block-settings/assets/6867360/5cdc6a92-4382-4c76-b132-5bf81bb8916d\"\u003e\n\nThe selected value will be added as a className to the block and saved as an attribute in the block's JSON data:\n\n```html\n\u003cdiv class=\"wp-block-button block-style-outline\"\u003e\n\t...\n\u003c/div\u003e\n```\n\n```json\n{\n\t\"prefixButtonStyle\": \"block-style-outline\"\n}\n```\n\n## Multiple values support\n\nIf you set `multiple` to true, your options will be rendered as checkboxes instead of a select dropdown.\n\n\u003cimg width=\"976\" alt=\"Xnapper-2024-06-13-15 40 02\" src=\"https://github.com/bacoords/block-settings/assets/6867360/ee67526a-8497-46bd-a25c-bafaade96d93\"\u003e\n\n\nThe selected values will be saved as an array in the block's JSON data:\n\n```json\n{\n\t\"prefixButtonStyle\": [ \"block-style-outline\", \"block-style-solid\" ]\n}\n```\n\nThis is also useful even if there's only one option but you want a checkbox/boolean behavior.\n\n\n## Potential next steps...\n- optional render_block attribute to enable modifying the block markup in one palce\n- some sort of conditional register_block_style support or inline CSS built in?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbacoords%2Fblock-settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbacoords%2Fblock-settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbacoords%2Fblock-settings/lists"}