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

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

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

wpdesk/wp-init

最新稳定版本:0.10.6

Composer 安装命令:

composer require wpdesk/wp-init

包简介

Bootstrap for a WordPress plugin

README 文档

README

Boot your plugin with superpowers.

Installation

To use this library in your project, add it to composer.json:

composer require wpdesk/wp-init

Creating a Plugin

Preferred method of using this library exercise Object Oriented Programming and organizing your actions and filters in a multiple classes, although it isn't the only way you can interact (and benefit from this library).

The plugin initialization consists of the following steps:

  1. Create a regular main plugin file, following header requirements
  2. Prepare DI container definitions for your services.
  3. Declare all classes included in hook binding.

The above limits your main plugin file to a short and simple structure.

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

use WPDesk\Init\Init;

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

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

Plugin configuration

For plugin configuration, you may focus on succinct, declarative configuration.

Supported configuration:

<?php

return [
	'hook_resources_path' => 'config/hook_providers',
	'services' => 'config/services.inc.php',
	'cache_path' => 'generated',

	'requirements' => [
		'plugins' => [
			'name' => 'woocommerce/woocommerce.php',
			'nice_name' => 'WooCommerce',
		]
	],

	'plugin_class_name' => 'Example\Plugin',
];

Usage with wpdesk/wp-builder

As a legacy support, it is possible to power up your existing codebase, which uses wpdesk/wp-builder with this library capabilities, as autowired services.

The only change, you have to do (besides configuration of services) is adding hookables as class string, ready for handling by DI container:

- $this->add_hookable( new \WPDesk\Init\Provider\I18n() );
+ $this->add_hookable( \WPDesk\Init\Provider\I18n::class );

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.

统计信息

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

GitHub 信息

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

其他信息

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