hoststyle/hswp-theme-builder 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hoststyle/hswp-theme-builder

最新稳定版本:v0.4.0

Composer 安装命令:

composer require hoststyle/hswp-theme-builder

包简介

关键字:

README 文档

README

First of all, if you are looking for a tool that gives you functions in the admin panel, you are in the wrong place!

This theme builder was created for developers. It aims to speed up and facilitate the development of WordPress themes.

Installation

Composer installation

Open Terminal on (Linux or MAC) or PowerShell (on Windows) insite the theme path and run:

composer require hoststyle/hswp-theme-builder

At the beginning of the functions.php file, insert the following line to import composer dependencies:

require_once __DIR__ .'/vendor/autoload.php';

Code examples

Let's create a basic Custom Post Type and Taxonomy.

Custom Post Type

Registering Custom Post Types with basic configurations:

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');

For complete guide, access the Custom Post Type complete documentation.

Taxonomy

Registering Taxonomy with basic configuration:

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');

For complete guide, access the Taxonomy complete documentation.

Global settings

To use global settings you can use Builder class and use for all Post Types or Taxonomies:

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);

Versioning

The current version is: v0.4.0

Version LOG

  • v0.4.0 23/07/2024 - Add meta box on custom post type
  • v0.3.0 23/07/2024 - Add admin custom pages and new form structure
  • v0.2.0 23/07/2024 - Add a custom text field to taxonomy
  • v0.1.1 23/07/2024 - Separate global settings
  • v0.1.0 13/07/2024 - Post Types and Taxonomies

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2024-07-05