wrd/wp-blocks
Composer 安装命令:
composer require wrd/wp-blocks
包简介
Simplifies the process for WordPress themes to create and write ACF Pro Blocks.
README 文档
README
Automatically creates blocks from the theme's blocks directory.
Usage
Use register_all_theme_blocks to register all blocks in the the themes' block directory. This defaults to blocks/.
You can use the wrd\wp-blocks\get_theme_blocks_dir filter to change the location of the theme's blocks dir.
Commands
You can use the following command to quickly generate a block, with optional ACF, CSS and JS files.
./vendor/bin/blocks --help
Registration
register_all_theme_blocks
Registers all blocks in the theme's block directory.
register_theme_block
Registers an individual block. Blocks are defined as a directory with a block.json file. Will also import an Advanced Custom Fields JSON file with the name acf.json if it exists.
register_block_category
Register a new block category.
set_include_theme_block_styles_before_render
Force WordPress to include block styles individually, with the block when it is rendered.
set_allowed_block_types
Whitelists the allowed blocks. Optionally whitelists a post type which is given a higher precedence.
set_use_block_editor
Enables or disables the block editor. Optionally takes a post type which is given a higher precedence.
set_use_inner_blocks_wrapper
Enable to disable the wrapper around inner blocks. Only works on the front-end.
set_use_core_styles
Used to dequeue the core block styles & global styles.
Templating Functions
block_atts
Output the block's attributes. You can pass attributes of your own to be merged in.
block_is_editor
Checks if the block is currently being rendered for preview in the block editor.
block_has_style
Check if the block has a style selected.
get_block_directory
Get the absolute filepath for the block's directory, with an optional append.
get_block_directory_uri
Get the URL for the block's directory, with an optional append.
get_prose_blocks
Prose blocks are a set of blocks that are typically allowed as text content.
the_inner_blocks
Display a slot for the user to add child blocks.
the_bg_image
Display a style attribute for a background image.
the_link
Easily display an ACF link field.
wrd/wp-blocks 适用场景与选型建议
wrd/wp-blocks 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 56 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 06 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 wrd/wp-blocks 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wrd/wp-blocks 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 56
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-09