定制 alexrah/wp-admin-custom-post-types 二次开发

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

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

alexrah/wp-admin-custom-post-types

Composer 安装命令:

composer require alexrah/wp-admin-custom-post-types

包简介

Requires a Wordpress installation. Helper Classes to create Wordpress Custom Post Types, Post Meta, Custom Taxonomies

README 文档

README

Helper class to register custom post_types and relative post_metas to Wordpress

Install using composer:

composer require alexrah/wp-admin-custom-post-types

published on packagist at: https://packagist.org/packages/alexrah/wp-admin-custom-post-types

Usage

use WpAdminCPT\RegisterTypes;
use WpAdminCPT\MetaFieldsManager;
use WpAdminCPT\MetaFieldsAdmin;

const META_BOX_NONCE = 'meta_box_nonce';

new RegisterTypes('user-paid-content',
	[
		'label_singular' => "My Post",
		'label_plural' => "My Posts"
	],
	true,
	[
		'label_singular' => "Categoria Contenuto",
		'label_plural' => "Categorie Contenuto"
	]
);

function vn_fields(): MetaFieldsManager {

	$sPrefix = 'user-paid-';

	$aFields = [
		[
			"Name"        => "type",
			"Label"       => "Tipo Contenuto",
			"LabelPublic" => "",
			"Placeholder" => "Seleziona Tipo",
			"Type"        => "select",
			"Validation"  => '',
			"Value"       => ['job-listing','event'],
			'Group'       => 'global'
		],
		[
			"Name"        => "candidati_comunali",
			"Label"       => "Candidati Consiglieri",
			"LabelPublic" => "",
			"Placeholder" => "",
			"Type"        => "data-grid",
			"Validation"  => '',
			"Group"       => 'global',
			"Value"       => [
				[
					'type' => 'text',
					'name' => 'nome',
					'label' => "Nome"
				],
				[
					'type' => 'text',
					'name' => 'cognome',
					'label' => "Cognome"
				],
				[
					'type' => 'text',
					'name' => 'voti',
					'label' => "Voti"
				],
				[
					'type' => 'checkbox',
					'name' => 'isEletto',
					'label' => "Eletto"
				]
			]

		]
	];

	return new MetaFieldsManager($sPrefix,$aFields);

}

$oUserPaidContent = new MetaFieldsAdmin(vn_fields()->getFields(),META_BOX_NONCE,['user-paid-content'],'Dati');
$oUserPaidContent->init();

RegisterTypes options

  • string $screen post_type screen IDs
  • array $args_post arguments to pass for registering post_types
    • label_singular string used for labels and define capability
    • label_plural string used for labels and define capability
    • menu_icon string dashicons class
    • slug string for custom rewrite rule
    • taxonomies array of taxonomy slugs
    • show_in_menu bool|string ie. edit.php?post_type=evento
    • supports array ie. 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments'
    • has_archive bool|string - Whether there should be post type archives, or if a string, the archive slug to use. Will generate the proper rewrite rules if $rewrite is enabled. Default false
    • bool $register_tax whether use screens IDs to register taxonomy
    • array $args_tax arguments to pass for registering taxonomy
    • label_singular string used for labels
    • label_plural string used for labels
    • cat_name string used to register taxonomy, if not specified use cat-$screens
    • linked_types (array|string) object types with which the taxonomy should be associated, Default to $screen
    • hierarchical bool Whether the taxonomy is hierarchical. Default true
    • slug string Customize the permalink slug. Default to cat-$screen
  • bool $register_tax whether use screens IDs to register taxonomy
  • array $args_tax arguments to pass for registering taxonomy
    • label_singular string used for labels
    • label_plural string used for labels
    • cat_name string used to register taxonomy, if not specified use cat-$screens
    • linked_types (array|string) object types with which the taxonomy should be associated, Default to $screen
    • hierarchical bool Whether the taxonomy is hierarchical. Default true
    • slug string Customize the permalink slug. Default to cat-$screen

MetaFieldsAdmin options

  • array $aMetaFields array of meta_fields as returned by MetaFieldsManager::getFields()
  • string $sNonce a unique string used to validate requests
  • array $aScreens an array of post_type IDs to register with
  • string $sBoxTitle a label for the meta_box

NB: go to /wp-admin/users.php?page=users-user-role-editor.php to update permissions

Changelog

version 1.0.0

  • helper classes to register post_types
  • supports creating custom taxonomies
  • support creating post_metas

version 2.0.0

change root dir for PHP classes from src to backend

version 2.1.0

add support to Rest API

Version 3.0

new post_meta type = data-grid -> React UX to manage multi-dimensional array data in a single post_meta

alexrah/wp-admin-custom-post-types 适用场景与选型建议

alexrah/wp-admin-custom-post-types 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 36 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 10 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「wordpress」 「wp」 「wp-admin」 「cpt」 「custom-taxonomy」 「custom-post-types」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 alexrah/wp-admin-custom-post-types 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 alexrah/wp-admin-custom-post-types 我们能提供哪些服务?
定制开发 / 二次开发

基于 alexrah/wp-admin-custom-post-types 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-20