publishpress/wordpress-version-notices
Composer 安装命令:
composer require publishpress/wordpress-version-notices
包简介
Library for displaying version notices for Pro plugins in WordPress.
README 文档
README
Description
Library for displaying ads for Pro plugins in WordPress.
Installation
$ composer require publishpress/wordpress-version-notices
Loading the library
The library is now loaded automatically by a special include file and Versions class generated by the lib PublishPress Version Loader Generator.
You just need to load the vendor/autoload.php file in your plugin or theme in the main context, out of any WP hook, including plugins_loaded.
Top Notice
add_filter(\PublishPress\WordpressVersionNotices\Module\TopNotice\Module::SETTINGS_FILTER, function ($settings) { $settings['dumb-plugin-one'] = [ 'message' => 'You\'re using Dumb Plugin One Free. Please, %supgrade to pro%s.', 'link' => 'http://example.com/upgrade', 'screens' => [ [ 'base' => 'edit', 'id' => 'edit-post', 'post_type' => 'post', ], ] ]; return $settings; });
Params
- message: Type the respective message for the banner, adding the button text between '%s'. This string will be used as format for
sprint. - link: The full link for the button.
- screen: An array of screen parameters used to decide what page should display the banner. Each item of the array can be a boolean or an array with a key-value array specifying the required params from the screen (WP_Screen) object. You can bypass the library's filter algorithm adding a
trueitem to it. This allows you to create your own function to check the screen returning a boolean value.
Menu link
add_filter(\PublishPress\WordpressVersionNotices\Module\MenuLink\Module::SETTINGS_FILTER, function ($settings) { $settings['dumb-plugin-one'] = [ 'label' => 'Upgrade', 'link' => 'http://example.com/upgrade', 'parent' => 'parent-menu-alias' ]; return $settings; });
If the plugin has alternative parent menus (in case some modules are disabled) you can specify a set of valid menus as parent. The first that is found as parent menu is used as the parent.
add_filter(\PublishPress\WordpressVersionNotices\Module\MenuLink\Module::SETTINGS_FILTER, function ($settings) { $settings['dumb-plugin-one'] = [ 'label' => 'Upgrade', 'link' => 'http://example.com/upgrade', 'parent' => [ 'parent-menu-alias-1', 'parent-menu-alias-2', 'parent-menu-alias-3', ] ]; return $settings; });
Params
- label: Type the respective label for the menu item.
- link: The full link for the menu link.
- parent: The parent menu we should add the link. A string or an array.
Testing
Create a new WordPress installation dedicated for testing.
Make sure to copy the file .env.testing.dist as .env.testing and update the variables according to your environment.
Install the dependencies using composer:
$ composer install
or
$ composer update
Run the script:
$ composer test
The scripts were implemented for *nix systems. Not adapted for Windows.
License
License: GPLv3 or later
publishpress/wordpress-version-notices 适用场景与选型建议
publishpress/wordpress-version-notices 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21.08k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 03 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 publishpress/wordpress-version-notices 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 publishpress/wordpress-version-notices 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 21.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2020-03-12