定制 micropackage/models 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

micropackage/models

最新稳定版本:1.0.0

Composer 安装命令:

composer require micropackage/models

包简介

Models

README 文档

README

BracketSpace Micropackage Latest Stable Version PHP from Packagist Total Downloads License

Micropackage logo

🧬 About Models

Package that simplifies registration of WordPress Model-like objects - Custom Post Types and Custom Taxonomies. Automatically generates name, slug and all required labels of Models.

💾 Installation

composer require micropackage/models

🕹 Usage

Adding new Custom Post Type

Classname of Post Types should ends with PostType.

<?php

use Micropackage\Models\PostType;

class TestimonialPostType extends PostType
{
	/**
	 * Define icon, whether post type should be public and other attributes.
	 * Labels will be generated automatically.
	 *
	 * @see https://developer.wordpress.org/reference/functions/register_post_type/
	 */
	protected static function getArgs(): array
	{
		return [
			'menu_icon' => 'dashicons-cart',
			'public' => true,
		];
	}
}

new TestimonialPostType();

Adding new Custom Taxonomy

Classname of Taxonomies should ends with Taxonomy.

<?php

use Micropackage\Models\Taxonomy;

class PlaceTaxonomy extends Taxonomy
{
	/**
	 * Define to which post types taxonomy should belongs.
	 *
	 * You can use slug of any post types or classname of post types created
	 * using this package.
	 */
	protected static array $objectTypes = [
		'product',
		TestimonialPostType::class,
	];

	/**
	 * Define whether taxonomy should be hierarchical and other attributes.
	 * Labels will be generated automatically.
	 *
	 * @see https://developer.wordpress.org/reference/functions/register_taxonomy/
	 */
	protected static function getArgs(): array
	{
		return [
			'hierarchical' => true,
		];
	}
}

new PlaceTaxonomy();

📦 About the Micropackage project

Micropackages - as the name suggests - are micro packages with a tiny bit of reusable code, helpful particularly in WordPress development.

The aim is to have multiple packages which can be put together to create something bigger by defining only the structure.

Micropackages are maintained by BracketSpace.

📖 Changelog

See the changelog file.

📃 License

GNU General Public License (GPL) v3.0. See the LICENSE file for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2023-03-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固