承接 ssnepenthe/wp-requirements 相关项目开发

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

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

ssnepenthe/wp-requirements

Composer 安装命令:

composer require ssnepenthe/wp-requirements

包简介

Helper for declaring dependencies in a WordPress plugin.

README 文档

README

Helper for declaring dependencies in a WordPress plugin.

Requirements

WordPress, PHP 5.3 or later and Composer.

Installation

Install using Composer:

$ composer require ssnepenthe/wp-requirements

Usage

This package provides a simple method for ensuring that WordPress plugins fail gracefully down to PHP 5.3.

Create a checker instance in your main plugin file (e.g. my-plugin/my-plugin.php):

use WP_Requirements\Plugin_Checker;

$checker = new Plugin_Checker( 'My Awesome Plugin', __FILE__ );

Where the first parameter is the name of your plugin (used for notifications when requirements are not met) and the second parameter is the path to your main plugin file (used to deactivate the plugin).

Then add any number of requirements. All of the following are valid:

// Verify that the Debug_Bar class exists - an indirect way of verifying that the Debug_Bar plugin is active.
$checker->class_exists( 'Debug_Bar' );

// Verify that the DOM extension is loaded.
$checker->extension_loaded( 'dom' );

// Verify that the cmb2_bootstrap() function exists - an indirect way of verifying that the CMB2 plugin is active.
$checker->function_exists( 'cmb2_bootstrap' );

// Verify that the server has PHP 5.4 or greater.
$checker->php_at_least( '5.4' );

// Verify that Hello Dolly is active.
// First parameter is plugin path relative to the plugin directory.
// Second parameter is plugin name used for label when requirement is not met.
$checker->plugin_active( 'hello.php', 'Hello Dolly' );

// Verify that the server has WordPress 4.7 or greater.
$checker->wp_at_least( '4.7' );

// Check any arbitrary condition.
// First parameter is a closure that should return true when the requirement is met, false otherwise.
// Second parameter is a message to display when the requirement is not met. Note that it will be prefixed with '{plugin name} deactivated: ' when it is displayed.
$checker->add_check(
    function() {
        return defined( 'SOME_CONSTANT' ) && SOME_CONSTANT;
    },
    'SOME_CONSTANT must be defined and truthy'
);

The Plugin_Checker class also provides a fluent interface:

use WP_Requirements\Plugin_Checker;

$checker = Plugin_Checker::make( 'My Awesome Plugin', __FILE__ )
    ->function_exists( 'cmb2_bootstrap' )
    ->php_at_least( '5.6' )
    ->wp_at_least( '4.7' );

Finally, verify all requirements are met and bootstrap your plugin accordingly.

if ( $checker->requirements_met() ) {
    // Whatever logic is required to bootstrap your plugin.
    // This should mostly take place outside of this file to minimize risk of errors when requirements are not met.
    $plugin = new My_Awesome_Plugin_Bootstrap;
    $plugin->init();
} else {
    // This method hooks in to 'admin_notices' to inform the user which requirements weren't met and 'admin_init' to actually deactivate the plugin.
    $checker->deactivate_and_notify();
}

ssnepenthe/wp-requirements 适用场景与选型建议

ssnepenthe/wp-requirements 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.48k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2017 年 04 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.48k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 18
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2017-04-09