hoststyle / hswp-theme-builder
v0.4.0
2024-08-01 19:11 UTC
This package is not auto-updated.
Last update: 2024-09-26 19:47:33 UTC
README
首先,如果您在寻找一个在管理面板中提供功能的工具,那么您找错地方了!
这个主题构建器 是为开发者创建的。它的目标是加快和简化WordPress主题的开发。
安装
Composer安装
在(Linux或MAC)上的Terminal
或Windows上的PowerShell
中打开主题路径,并运行
composer require hoststyle/hswp-theme-builder
在functions.php
文件的开始处,插入以下行以导入composer依赖项
require_once __DIR__ .'/vendor/autoload.php';
代码示例
让我们创建一个基本的自定义帖子类型和分类。
自定义帖子类型
使用基本配置注册自定义帖子类型
use HS\ThemeBuilder\PostType\PostType;
function build_custom_post_types()
{
// Initialize the class
$ptype = new PostType();
// Set the post type name "cpt_product" with singular and plural labels
$ptype->register('cpt_product', 'product', 'products');
}
add_action('init', 'build_custom_post_types');
要获取完整指南,请访问自定义帖子类型完整文档。
分类
使用基本配置注册分类
use HS\ThemeBuilder\Taxonomy\Taxonomy;
function build_taxonomies()
{
// Initialize the class
$tax = new Taxonomy();
// Add post types to use taxonomy
$tax->addPostTypes('cpt_product');
// Set the post type name "tax_type" with singular and plural labels
$tax->register('tax_type', 'type', 'types');
}
add_action('init', 'build_taxonomies');
要获取完整指南,请访问分类完整文档。
全局设置
要使用全局设置,您可以使用Builder
类,用于所有帖子类型或分类
use HS\ThemeBuilder\Builder;
use HS\ThemeBuilder\PostType\PostType;
use HS\ThemeBuilder\Taxonomy\Taxonomy;
$builder = new Builder();
// Set language of all labels
$builder->setLang('pt-br', true);
// Use prefix for names (default is 'cpt_' and 'tax_')
$builder->setPrefix(true);
// Use in Post Type
$ptype = new PostType($builder);
// Use in Taxonomy
$tax = new Taxonomy($builder);
版本控制
当前版本是:v0.4.0
版本日志
- v0.4.0 23/07/2024 - 在自定义帖子类型上添加元框
- v0.3.0 23/07/2024 - 添加管理自定义页面和新表单结构
- v0.2.0 23/07/2024 - 在分类中添加自定义文本字段
- v0.1.1 23/07/2024 - 分离全局设置
- v0.1.0 13/07/2024 - 帖子类型和分类