raytechhosting / wpabstractclasses
此包提供用于WordPress的面向对象的抽象包装PHP类,有助于加速开发。
0.11.7
2024-07-22 19:44 UTC
Requires
- php: >=7.4
- symfony/yaml: ^6.2
- dev-main
- 0.11.7
- 0.11.6
- 0.11.5
- 0.11.4
- 0.11.3
- 0.11.2
- 0.11.1
- 0.11.0
- 0.10.2
- 0.10.1
- 0.10.0
- 0.9.0
- 0.8.7
- 0.8.6
- 0.8.5
- 0.8.4
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.1
- 0.6.0
- 0.5.0
- 0.4.0
- 0.3.5
- 0.3.4
- 0.3.1
- 0.3.0
- 0.2.0
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-develop
- dev-release/0.11.7
- dev-release/0.11.6
- dev-release/0.12.0
This package is auto-updated.
Last update: 2024-09-17 01:15:35 UTC
README
此包提供用于WordPress的面向对象的抽象包装PHP类,有助于加速开发。
安装
使用composer安装是此包支持的安装方法。
composer require raytechhosting/wpabstractclasses
用法
首先在主题或插件文件夹的根目录下创建一个'.rtabstract.yml'文件。以下是如何设置此文件的示例。
implementation_type: theme
theme_name: theme-name
theme_version: 1.0.0
post_types:
portfolio:
tags: true
categories: true
supports:
- title
- editor
- thumbnail
meta_boxes:
meta:
columns: 3
label: Meta
fields:
name:
type: text
label: Name
test:
type: repeater
label: Tester
attr:
fields:
tester:
type: number
label: Tester
然后将以下代码片段添加到您的functions.php文件中。
require_once __DIR__ . '/vendor/autoload.php' ;
use RayTech\WPAbstractClasses\Factory\PostTypeFactory;
use RayTech\WPAbstractClasses\Utilities\Configuration;
// Read the configuration file.
$config = new Configuration();
// Creates the post types.
if ( isset( $config->data['post_types'] ) ) {
foreach ( $config->data['post_types'] as $conventions_post_type => $args ) {
PostTypeFactory::create( $conventions_post_type, $args );
}
}