wpdesk/wp-init 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

wpdesk/wp-init

Composer 安装命令:

composer require wpdesk/wp-init

包简介

Bootstrap for a WordPress plugin

README 文档

README

wp-init keeps WordPress plugin bootstrapping in one small entrypoint and one declarative config file. It wires PHP-DI services, hookable classes, optional modules, boot gates, and activation/deactivation handlers.

Installation

For the core bootstrap library:

composer require wpdesk/wp-init

For WP Desk free plugin defaults, install the free preset package instead:

composer require wpdesk/wp-init-plugin-free

For WP Desk paid plugin defaults, install the paid preset package:

composer require wpdesk/wp-init-plugin-paid

The preset packages install wpdesk/wp-init and the packages required by their modules.

Bootstrapping a plugin

Keep the main plugin file minimal:

<?php
/**
 * Plugin Name: Example Plugin
 */

use WPDesk\Init\Init;

require __DIR__ . '/vendor/autoload.php';

Init::setup( __DIR__ . '/config.php' )->boot();

The config file may be minimal:

<?php

return [
	'services' => __DIR__ . '/config/services.php',
	'hooks' => __DIR__ . '/config/hooks',
];

WP Desk plugin presets are enabled explicitly through modules:

<?php

use WPDesk\Init\PluginFree\FreePluginModule;
use WPDesk\Init\PluginFree\RequirementsModule;
use WPDesk\Init\PluginFree\WPDeskTrackerModule;

return [
	'services' => __DIR__ . '/config/services.php',
	'hooks' => __DIR__ . '/config/hooks',
	'cache_path' => 'generated',
	'environment' => 'production',
	'modules' => [
		FreePluginModule::class => null,
		RequirementsModule::class => [
			'requirements' => [
				'plugins' => [
					[
						'name' => 'woocommerce/woocommerce.php',
						'nice_name' => 'WooCommerce',
					],
				],
			],
		],
		WPDeskTrackerModule::class => [
			'shops' => [
				'default' => 'https://wpdesk.net',
				'pl_PL' => 'https://www.wpdesk.pl',
			],
		],
	],
	'gates' => [
		\Vendor\Plugin\Infrastructure\CustomCompatibilityGate::class,
	],
	'activate' => [
		static function ( \Vendor\Plugin\Migrations $migrations ): void {
			$migrations->migrate();
		},
	],
	'deactivate' => [
		\Vendor\Plugin\Hooks\CleanupOnDeactivate::class,
	],
];

Main concepts:

  • Hookable classes are the primary way to register WordPress hooks.
  • Callable bindings are for small one-shot boot or lifecycle work.
  • Modules are explicit opt-in bootstrap features with module-owned config.
  • Boot gates stop the plugin before normal hook registration when viability checks fail.
  • Activation and deactivation are handled explicitly through activate and deactivate config.

See configuration for the full config shape, legacy migration for wp-builder migration, and prefixing for PHP-Scoper setup.

Credits

This package is heavily inspired by Cedaro's wp-plugin and Alain Schlesser's basic-scaffold.

License

Copyright (c) 2024 WPDesk

This library is licensed under MIT.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固