定制 lapsrj/wp-dependencies-manager 二次开发

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

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

lapsrj/wp-dependencies-manager

Composer 安装命令:

composer require lapsrj/wp-dependencies-manager

包简介

Library that helps WordPress plugin dependency management.

README 文档

README

  • Tags: plugin, dependency, install
  • Requires at least: 5.1
  • Requires PHP: 5.6
  • License: MIT

A lightweight WordPress library for managing plugin dependencies. Declare required and recommended plugins via JSON, auto-install and activate them, and provide admins with a Dependencies page under the Plugins menu. Supports WordPress.org, GitHub, GitLab, Bitbucket, Gitea, direct URLs, and bundled ZIP files.

Based on WP Dependency Installer.

Description

You can use composer to install this package within your WordPress plugin / theme.

  1. Within your plugin or theme root folder, run the following command:
composer require lapsrj/wp-dependencies-manager
  1. Then create a wp-dependencies.json file:
[
  {
    "name": "Classic Editor",
    "host": "wordpress",
    "slug": "classic-editor/classic-editor.php",
    "uri": "https://wordpress.org/plugins/classic-editor/",
    "required": true
  },
  {
    "name": "Query Monitor",
    "host": "wordpress",
    "slug": "query-monitor/query-monitor.php",
    "uri": "https://wordpress.org/plugins/query-monitor/",
    "optional": true
  }
]
  1. Add the following lines to your plugin or theme's functions.php file:
require_once __DIR__ . '/vendor/autoload.php';
add_action( 'after_setup_theme', static function() {
  WP_Dependencies_Manager::instance( __DIR__ )->run();
});

For plugins, use the plugins_loaded hook instead of after_setup_theme.

Bundled Plugins (Local ZIP)

You can bundle plugin ZIP files directly within your theme or plugin to distribute premium or private plugins. Place the ZIP file in a directory (e.g. bundled-plugins/) and reference it using "host": "local":

{
  "name": "My Premium Plugin",
  "host": "local",
  "slug": "my-premium-plugin/my-premium-plugin.php",
  "uri": "bundled-plugins/my-premium-plugin.zip",
  "required": true
}

The uri is a relative path from your theme or plugin root to the ZIP file.

Using PHP instead of JSON

You can also register dependencies programmatically, which works the same way for bundled plugins:

require_once __DIR__ . '/vendor/autoload.php';
add_action( 'after_setup_theme', static function() {
  $manager = WP_Dependencies_Manager::instance( __DIR__ );
  $manager->register( [
    [
      'name'     => 'My Premium Plugin',
      'host'     => 'local',
      'slug'     => 'my-premium-plugin/my-premium-plugin.php',
      'uri'      => 'bundled-plugins/my-premium-plugin.zip',
      'required' => true,
    ],
    [
      'name'     => 'Classic Editor',
      'host'     => 'wordpress',
      'slug'     => 'classic-editor/classic-editor.php',
      'uri'      => 'https://wordpress.org/plugins/classic-editor/',
      'required' => true,
    ],
  ], __DIR__ );
  $manager->run();
});

When using register() directly, pass the caller directory as the second argument so that local paths resolve correctly.

Contributors

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固