builtnorth/extended-cpts-extras
Composer 安装命令:
composer require builtnorth/extended-cpts-extras
包简介
Additional functionality and features for johnbillion/extended-cpts
README 文档
README
Extended CPTs Extras is a companion package for the Extended CPTs library, providing additional functionality for managing post types in WordPress.
Features
-
Featured Image Column Width: Customize the width of the featured image column in the admin list view.
-
Remove Meta Boxes: Easily remove unwanted meta boxes from the post edit screen (useful for Gutenberg).
-
Register Meta: Register custom meta fields for your post types with support for the REST API.
-
Register Block Bindings: Register custom block binding sources for dynamic content in blocks.
-
Modify Existing Post Types: Add additional features to existing post types. Note that the the below features work correctly out of the box on the Extended CPTs package when registeting a new post type. It is only necessary to use the
extended_post_type_modify_existing()function when modifying an existing post type. Theses features include:- Custom templates
- Template locking
- Menu position
- Menu icon
Installation
-
Require the package in your
composer.json:{ "require": { "builtnorth/extended-cpts-extras": "^1.0" } } -
Run
composer installorcomposer update.
Usage
Use the extended_post_type_extras() function to apply extra configurations to post types:
extended_post_type_extras(['post', 'page'], [ 'featured_image_column_width' => 80, 'remove_meta_boxes' => ['postcustom', 'commentstatusdiv'], 'register_meta' => [ 'my_custom_field' => [ 'type' => 'string', 'description' => 'A custom field for this post type', 'single' => true, 'show_in_rest' => true, ], ], 'register_block_bindings' => [ 'my_custom_source' => [ 'label' => 'My Custom Source', 'get_value_callback' => function($source_args, $block_instance) { // Return dynamic content based on source_args return get_post_meta($block_instance->context['postId'], $source_args['key'], true); }, 'uses_context' => ['postId', 'postType'], ], ] ]);
Use function extended_post_type_modify_existing() function to modify existing post types:
extended_post_type_modify_existing('post', [ 'menu_icon' => 'dashicons-index-card', 'menu_position' => 30, 'template' => [ ['core/image', []], ], ]);
Functions
extended_post_type_extras($post_types, $options)
Apply extra configurations to specified post types.
Parameters:
$post_types: String or array of post type names$options: Array of configuration optionsfeatured_image_column_width: Set width for featured image columnremove_meta_boxes: Array of meta box IDs to removeregister_meta: Array of meta fields to registerregister_block_bindings: Array of block binding sources to register
extended_post_type_modify_existing($post_types, $options)
Modify existing post types with additional features that are not available in the original Extended CPTs package. This function allows you to apply certain options to existing post types that normally only work when registering a new post type with register_extended_post_type(). Specifically, it enables you to modify the following attributes for existing post types:
$post_types: String or array of post type names$options: Array of configuration optionstemplate: Custom template for the post typetemplate_lock: Lock the template to prevent changesmenu_position: Set the menu positionmenu_icon: Set the menu icon
Contributing
Contributions are welcome. Please feel free to submit a Pull Request.
License
This package is open-sourced software licensed under the MIT license.
builtnorth/extended-cpts-extras 适用场景与选型建议
builtnorth/extended-cpts-extras 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 266 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 09 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 builtnorth/extended-cpts-extras 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 builtnorth/extended-cpts-extras 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 266
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2024-09-06