承接 camalote-wp/models 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

camalote-wp/models

Composer 安装命令:

composer require camalote-wp/models

包简介

CamaloteWP Models provides abstract base classes for registering WordPress content models (post types, taxonomies, metadata, blocks).

README 文档

README

Abstract base classes for registering WordPress content models (post types, meta, blocks, REST hooks, admin pages). Reduces boilerplate when spinning up the same registration logic across multiple plugins.

Usage

  1. Extend the abstracts for your content model
  2. Implement the abstract methods
  3. List your components in a Bootstrap class
  4. Run the BootstrapRunner
use CamaloteWP\Models\Core\BootstrapRunner;

$runner = new BootstrapRunner;
$runner->register([Page\Bootstrap::class])->run();

Complete Example

// PagePostType.php
namespace MyPlugin\Page;

use CamaloteWP\Models\Abstracts\AbstractPostType;

class PagePostType extends AbstractPostType
{
    protected string $model_name = 'page';

    protected function args(): array
    {
        return [
            'public'       => true,
            'has_archive'  => true,
            'show_in_rest' => true,
            'labels' => [
                'name' => 'Pages',
                'singular_name' => 'Page',
            ],
        ];
    }
}
// PageMeta.php
namespace MyPlugin\Page;

use CamaloteWP\Models\Abstracts\AbstractMeta;

class PageMeta extends AbstractMeta
{
    protected string $model_name = 'page';

    protected function schema(): array
    {
        return [
            'subtitle' => ['type' => 'string'],
            'color'    => ['type' => 'string'],
        ];
    }

    protected function get_meta_prefix(): string
    {
        return 'page_';
    }
}
// PageBlocks.php
namespace MyPlugin\Page;

use CamaloteWP\Models\Abstracts\AbstractBlocks;

class PageBlocks extends AbstractBlocks
{
    protected string $model_name = 'page';

    protected function get_block_paths(): array
    {
        return [get_template_directory() . '/blocks'];
    }
}
// Bootstrap.php
namespace MyPlugin\Page;

use CamaloteWP\Models\Abstracts\AbstractBootstrap;

class Bootstrap extends AbstractBootstrap
{
    protected string $model_name = 'page';

    public function get_components(): array
    {
        return [
            PagePostType::class,
            PageMeta::class,
            PageBlocks::class,
        ];
    }
}
// In your plugin's main file or service provider
use CamaloteWP\Models\Core\BootstrapRunner;
use MyPlugin\Page\Bootstrap;

$runner = new BootstrapRunner;
$runner->register([Bootstrap::class])->run();

Reference

AbstractPostType

What to extend AbstractPostType
Implements Registerable
Must implement args(): array
Can override (none)
You get register() — calls \register_post_type() with $model_name and args()

AbstractMeta

What to extend AbstractMeta
Implements Registerable
Must implement schema(): array
Can override get_meta_prefix(): string (default: empty string)
You get register() — loops schema and calls \register_post_meta() per entry, prefixing keys with get_meta_prefix()

AbstractBlocks

What to extend AbstractBlocks
Implements Registerable, Hookable
Must implement get_block_paths(): array
Can override get_hooks(): array (default: empty)
You get register() — scans each path for block.json files and calls \register_block_type()

AbstractRest

What to extend AbstractRest
Implements Hookable
Must implement (none)
Can override get_hooks(): array (default: empty)
You get A Hookable base for adding REST filters/actions via get_hooks()

AbstractModelAdminPage

What to extend AbstractModelAdminPage
Implements Hookable, AdminPage
Must implement get_page_config(): array, get_asset_config(): array, render_page(): void
Can override get_hooks(): array (default: empty)
You get register_submenu_page(), register_menu_page(), enqueue_assets()

AbstractBootstrap

What to extend AbstractBootstrap
Must implement get_components(): array
Can override register() (default: empty)
You get get_model_name()

BootstrapRunner

Orchestrates registration. Instantiate, pass Bootstrap class names to register(), then call run().

$runner = new BootstrapRunner;
$runner->register([Bootstrap::class])->run();

Installation

composer require camalote-wp/models

Development

composer test          # Run tests
composer stan          # Run static analysis
composer pint          # Check code style
composer check         # Run all three

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-06-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固