marcosnunesmbs/wpcreator

Wordpress CPT 构建器

1.1.1 2023-08-06 15:05 UTC

This package is auto-updated.

Last update: 2024-09-16 23:37:52 UTC


README

Build Status Latest Stable Version License

描述

一个简单的php cli,用于通过yaml文件创建Wordpress自定义文章类型、Elementor的小部件以及其他实用程序。

入门指南

安装

此CLI应用程序是一个用PHP编写的Wordpress自定义文章类型构建器,使用Composer进行安装

composer global require marcosnunesmbs/wpcreator

用法

创建自定义文章类型

  1. 创建一个名为example.yamlexample.json的文件,包含基本信息
name: Cars
labels:
  plural: Cars
  singular: Car
  menuName: Cars
  slug: cars
supports: title thumbnail
taxonomies:
  - name: Manufacturer
    singular: Manufacturer
    plural: Manufacturers
    slug: manufacturer
    hierarchical: 'true'
metaboxes:
  - name: form_car
    title: Form
    postmetas:
      - id: model_car
        label: Model
        type: text
      - id: old_car
        label: Old
        type: text
  - name: form2
    title: Form 2
    postmetas:
      - id: purchase_date
        label: Purchase Date
        type: date
{
    "name": "Cars",
    "labels": {
      "plural": "Cars",
      "singular": "Car",
      "menuName": "Cars"
    },
    "slug": "car",
    "supports": "title thumbnail",
    "taxonomies": [
      {
        "name": "Manufacturer",
        "singular": "Manufacturer",
        "plural": "Manufacturers",
        "slug": "manufacturer",
        "hierarchical": "true"
      }
    ],
    "metaboxes": [
      {
        "name": "form_car",
        "title": "Form",
        "postmetas": [
          {
            "id": "model_car",
            "label": "Model",
            "type": "text"
          },
          {
            "id": "old_car",
            "label": "Old",
            "type": "text"
          }
        ]
      },
      {
        "name": "form2",
        "title": "Form 2",
        "postmetas": [
          {
            "id": "purchase_date",
            "label": "Purchase Date",
            "type": "date"
          }
        ]
      }
    ]
  }
  

更多示例

  1. 执行命令 create:cpt,后跟yaml路径
wpcreator create:cpt example.yaml

此命令将在名为 "output" 的文件夹中创建一个名为 Cars.php 的文件,该文件包含自定义文章类型的基本配置。