johnbillion / extended-cpts
这是一个库,为WordPress的自定义文章类型和分类提供了扩展功能。
Requires
- php: >= 7.4.0
- johnbillion/args: ^1.4.1
Requires (Dev)
- automattic/phpcs-neutron-standard: 1.7.0
- dealerdirect/phpcodesniffer-composer-installer: ^0.7
- johnbillion/falsey-assertequals-detector: *
- johnbillion/plugin-infrastructure: dev-trunk
- lucatume/wp-browser: >=3.0.21 <3.5
- phpcompatibility/phpcompatibility-wp: ^2
- phpstan/phpstan: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- roots/wordpress-core-installer: ^1.0.0
- roots/wordpress-full: *
- szepeviktor/phpstan-wordpress: 1.1.6
- wp-coding-standards/wpcs: 2.3.0
- dev-develop
- 5.0.8
- 5.0.7
- 5.0.6
- 5.0.5
- 5.0.4
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0.0
- 4.5.2
- 4.5.1
- 4.5.0
- 4.4.1
- 4.4.0
- 4.3.3
- 4.3.2
- 4.3.1
- 4.3.0
- 4.2.6
- 4.2.5
- 4.2.4
- 4.2.3
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.0
- 4.0.2
- 4.0.1
- 4.0.0
- 3.2.1
- 3.2.0
- 3.1.0
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.5.2
- 2.5.1
- 2.5
- 2.4
- 2.3.3
- 2.3.2
- 2.3.1
- dev-update-plugin-infrastructure/johnbillion/plugin-infrastructure/stable-stubs
- dev-wp-compat
- dev-update-plugin-infrastructure/johnbillion/plugin-infrastructure/actions-sast
- dev-update-plugin-infrastructure-to-actions-sast
- dev-trunk
This package is auto-updated.
Last update: 2024-09-07 20:11:07 UTC
README
Extended CPTs
Extended CPTs是一个库,它为WordPress的自定义文章类型和分类提供了扩展功能。这允许开发者快速构建文章类型和分类,无需重复编写相同的代码。
Extended CPTs与块编辑器和经典编辑器都兼容。
不是第一次来了?请查看开发者的最近更改以了解Extended CPTs最近版本中的新功能。
改进的文章类型默认设置
- 自动生成的标签和文章更新消息(英文)
- 公共文章类型,启用管理员UI和文章缩略图
- 具有
page
功能类型的层次结构 - 最佳的管理员菜单位置
改进的分类默认设置
- 自动生成的标签和术语更新消息(英文)
- 启用了管理员UI的层次结构公共分类
扩展管理员功能
- 在文章类型列表屏幕上声明性地创建表列
- 用于文章元数据、分类术语、特色图片、文章字段、Posts 2 Posts连接和自定义函数的列
- 可排序的列用于文章元数据、分类术语和文章字段
- 用户能力限制
- 默认排序列和排序顺序
- 在分类术语列表屏幕上声明性地创建表列
- 用于术语元数据和自定义函数的列
- 用户能力限制
- 在文章类型列表屏幕上启用按文章元数据、分类术语、文章作者和文章日期过滤的筛选控件
- 覆盖“特色图片”和“在此处输入标题”文本
- 在文章编辑屏幕上的分类中提供几个自定义元框
- 简化的复选框列表
- 单选按钮
- 下拉菜单
- 自定义函数
- 将文章类型自动添加到仪表板上的“快速概览”部分
- 可选地将文章类型添加到仪表板上的“最近发布”部分
文章类型的扩展前端功能
- 指定自定义永久链接结构
- 例如
reviews/%year%/%month%/%review%
- 支持所有相关重写标签,包括日期和自定义分类
- 与Rewrite Rule Testing插件自动集成
- 例如
- 指定公共查询变量,启用按文章元数据和文章日期过滤
- 指定公共查询变量,启用按文章元数据、分类术语和文章字段排序
- 覆盖默认的公共或私有查询变量,如
posts_per_page
、orderby
、order
和nopaging
- 将文章类型添加到网站的主RSS源
最低要求
- PHP 7.4
- 已测试至PHP 8.3
- WordPress 5.7
- 已测试至WP 6.6
安装
Extended CPTs是一个开发者库,而不是插件,这意味着您需要将其作为项目依赖项包含在内。使用Composer进行安装
composer require johnbillion/extended-cpts
其他安装或使用方式,尤其是插件内的捆绑,不支持官方使用,且风险自负。
使用
需要简单的文章类型,无需装饰?您可以仅用一个参数注册一个文章类型
add_action( 'init', function() { register_extended_post_type( 'article' ); } );
您也可以仅用两个参数注册一个分类
add_action( 'init', function() { register_extended_taxonomy( 'location', 'article' ); } );
试一试。您将拥有一个具有管理员界面的分层公共文章类型,一个具有管理员界面的分层公共分类,以及所有自动生成的标签和更新消息。
或者想要更多功能
add_action( 'init', function() { register_extended_post_type( 'story', [ # Add the post type to the site's main RSS feed: 'show_in_feed' => true, # Show all posts on the post type archive: 'archive' => [ 'nopaging' => true, ], # Add some custom columns to the admin screen: 'admin_cols' => [ 'story_featured_image' => [ 'title' => 'Illustration', 'featured_image' => 'thumbnail' ], 'story_published' => [ 'title_icon' => 'dashicons-calendar-alt', 'meta_key' => 'published_date', 'date_format' => 'd/m/Y' ], 'story_genre' => [ 'taxonomy' => 'genre' ], ], # Add some dropdown filters to the admin screen: 'admin_filters' => [ 'story_genre' => [ 'taxonomy' => 'genre' ], 'story_rating' => [ 'meta_key' => 'star_rating', ], ], ], [ # Override the base names used for labels: 'singular' => 'Story', 'plural' => 'Stories', 'slug' => 'stories', ] ); register_extended_taxonomy( 'genre', 'story', [ # Use radio buttons in the meta box for this taxonomy on the post editing screen: 'meta_box' => 'radio', # Add a custom column to the admin screen: 'admin_cols' => [ 'updated' => [ 'title_cb' => function() { return '<em>Last</em> Updated'; }, 'meta_key' => 'updated_date', 'date_format' => 'd/m/Y' ], ], ] ); } );
砰!现在我们有
- 一个“故事”文章类型,具有正确生成的标签和文章更新消息,管理员区域中的三个自定义列(其中两个可排序),添加到主RSS源的故事,以及所有故事都显示在文章类型存档中。
- 与“故事”文章类型相关联的“类型”分类,具有正确生成的标签和术语更新消息,以及管理员区域中的一个自定义列。
register_extended_post_type()
和 register_extended_taxonomy()
函数最终是WordPress核心中 register_post_type()
和 register_taxonomy()
函数的包装器,因此可以使用那些函数的任何参数。
您还可以做更多。请参阅Wiki获取完整文档。
贡献和测试
有关贡献信息,请参阅CONTRIBUTING.md
许可证:GPLv2或更高版本
本程序是免费软件;您可以在自由软件基金会发布的GNU通用公共许可证的条款下重新分发和/或修改它;许可证的第二版,或者(根据您的选择)任何更高版本。
本程序的分发是希望它有用,但没有任何保证;甚至没有关于其商售性或适用于特定目的的暗示保证。有关详细信息,请参阅GNU通用公共许可证。