wp-media/plugin-family 问题修复 & 功能扩展

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

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

wp-media/plugin-family

Composer 安装命令:

composer require wp-media/plugin-family

包简介

Organizes and displays WP Media plugin family across other members.

README 文档

README

This package bundles the WP Media plugin collection within a single plugin.

Functionality

This package gathers essential data about each member plugin and provides their installation and activation links, similar to the Imagify Partner package. It returns an installation link for plugins that are not installed, and an activation link for those that are installed but not active. For Imagify, the link generated by the Imagify Partner package is used.

PS: The Imagify Partner package needs be installed along side. refer here for more information.

Installations & Configurations

Mozart

It is strongly advised that this package is loaded using Mozart. This is to avoid package conflicts where the same package is being used in another plugin and loaded from the same namespace. So please, take the pain to install mozart as a development dependency of your plugin: composer require coenjacobs/mozart --dev

  • After installation, now you are set to configure mozart: see here or simply refer to how it's done on wp-rocket here, there's no shame.
  • Lastly setup (post install & update) scripts as done here

Package

Now for the package, we need to come back to composer.json file again.

  • Remember the extra key we added while setting up mozart some minutes ago, Bingo! Add a new property in it like this: "plugin_domain": "your_text_domain". Replace your_text_domain with your actual text domain. e.g for WP Rocket, it's rocket

  • Now again, remember the (post install & update) script we also created, we'll add new properties there also like this:

    "post-install-cmd": [
        "Mozart\\dep_namespace\\WPMedia\\PluginFamily\\PostInstall::apply_text_domain"
    ],
    "post-update-cmd": [
        "Mozart\\dep_namespace\\WPMedia\\PluginFamily\\PostInstall::apply_text_domain"
    ],

    Replace Mozart\\dep_namespace with the dep_namespace you configured for mozart earlier.

    PS: The example above doesn't not take into consideration the mozart scripts. so don't copy directly and overwrite your scripts.

  • Finally, install using composer: composer require wp-media/plugin-family

Usage Instructions

  • Import the model that holds the filtered data into your view class.
use WPMedia\PluginFamily\Model\PluginFamily;

class View {
    protected $plugin_family;

    public function __construct( $plugin_family ) {
        $this->plugin_family = $plugin_family;
    }

    public function display_page() {
		$plugin_family = $this->plugin_family->get_filtered_plugins( 'imagify/imagify' );

		$data = [
			'plugin_family' => $plugin_family['uncategorized'],
		];

		$this->print_template( 'page-settings', $data );
	}
}

The model returns an array with 2 keys ( categorized & uncategorized ). This for plugins like WP Rocket that needs to display the plugins by category.

  • The categorized version has the plugins grouped by their categories.
  • The uncategorized version is the reverse of the former.

Next, we need to invoke the controller responsible for managing the installation and activation. This controller has a corresponding interface that needs to be implemented.

use WPMedia\PluginFamily\Controller\{ PluginFamily, PluginFamilyInterface };

class Subscriber implements SubscriberInterface, PluginFamilyInterface {

    protected $plugin_family;

    public function __construct( $plugin_family ) {
        $this->plugin_family = $plugin_family;
    }

	public static function get_subscribed_events() {
        $events = PluginFamily::get_subscribed_events();

        return $events;
	}

    public function install_activate() {
        $this->plugin_family->install_activate();
    }

    public function display_error_notice() {
        $this->plugin_family->display_error_notice();
    }
}

The methods ( install_activate & display_error_notice ) are required.

PS: This example is based on the assumption that your plugin utilizes EDA. If EDA is not implemented, you can iterate through the events returned by PluginFamily::get_subscribed_events() and use add_action accordingly.

Development & Testing

To facilitate development and testing of the package, it is recommended to specify a development branch in the composer.json file of your project.

Taking WP Rocket as example

"require": {
    "wp-media/plugin-family": "dev-whatever-dev-branch"
}

PS: Always have the dev prefix before the actual branch.

"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/wp-media/plugin-family"
        }
    ]

wp-media/plugin-family 适用场景与选型建议

wp-media/plugin-family 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 481.88k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 10 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 wp-media/plugin-family 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2024-10-21