voceconnect / wp-contextual-help
WordPress 插件,允许开发者轻松扩展 WordPress 中的上下文帮助下拉内容区域
This package is not auto-updated.
Last update: 2022-02-01 12:37:17 UTC
README
请注意:此插件不再积极维护或支持。
WP 上下文帮助
贡献者:kevinlangleyjr, voceplatforms, Mte90
标签:上下文,帮助
最低要求:3.3
测试到:4.1
稳定标签:1.0.2
许可证:GPLv2 或更高版本
许可证 URI:https://gnu.ac.cn/licenses/gpl-2.0.html
允许开发者轻松扩展 WordPress 中的上下文帮助下拉内容区域。
描述
添加辅助功能,以便轻松向整个 WordPress 网站的 admin 中添加 WP 上下文帮助。
安装
作为标准插件
见 安装插件。
作为主题或插件依赖
将插件拖放到包含的主题或插件中后,添加以下内容
if( ! class_exists( 'WP_Contextual_Help' ) ) { require_once( $path_to_help . '/wp-contextual-help.php' ); }
作为 composer 依赖项
将以下内容添加到 composer.json 的 required 依赖项中
{ // ... "require": { "voceconnect/wp-contextual-help": "~0.0.1" // Most recent tagged version }, // ... }
用法
在注册选项卡时,您可以根据需要显示的内容选择一些不同的选项。
如果在选项卡参数中提供回调参数,则该参数将具有优先权,插件将不会在帮助文档目录中查找任何 HTML 文件。
如果在选项卡参数中提供文件参数,则插件将专门查找该文件,如果不存在,将输出警告消息以通知开发者指定的帮助文档不存在。
如果没有在选项卡参数中传递文件或回调参数,则默认情况下,插件将查找与选项卡 ID 相同名称的文件。因此,对于 post-management
,它将在帮助文档目录中查找 post-management.html
。
HTML 帮助文档
所有帮助文档应位于 get_template_directory() . '/includes/help-docs/'
目录中,所有图像位于 get_template_directory() . '/includes/help-docs/img/'
您可以使用 wp_contextual_help_docs_dir
过滤器更改 HTML 文件的目录,使用 wp_contextual_help_docs_url
过滤器更改图像的基本 URL。在您的帮助文档中,我们使用变量 {WP_HELP_IMG_URL}
作为图像 URL 的占位符,然后在渲染之前用过滤器提供的值替换,默认情况下为默认帮助文档图像目录。
注册选项卡
使用 WP_Contextual_Help::register_tab()
方法注册帮助选项卡。
参数
$id
(字符串) - 用于帮助选项卡的ID字符串$title
(字符串) - 在选项卡中显示给用户的标题$args
(数组) - 帮助选项卡的选项数组page
(字符串,数组) - 启用帮助选项卡的页面(页码)post_type
(字符串,数组) - 限制选项卡仅在特定文章类型上显示file
(字符串) - 读取并输出到选项卡中的HTML文件wpautop
(布尔值) - 默认:False - 对加载的HTML文件应用wpautopcallback
- 如果用户更愿意使用自定义回调而不是自动加载HTML文件,则在这里应用
示例
<?php add_action( 'init', function(){ if( !class_exists( 'WP_Contextual_Help' ) ) return; // Only display on the pages - post.php and post-new.php, but only on the `post` post_type // This would automatically look for a file called post-management.html within get_template_directory() . '/includes/help-docs/'; WP_Contextual_Help::register_tab( 'post-management', 'Post Management', array( 'page' => array( 'post.php', 'post-new.php' ), 'post_type' => 'post', 'wpautop' => true ) ); // Add to a custom admin page WP_Contextual_Help::register_tab( 'custom-settings', 'Custom Settings', array( 'page' => 'settings_page_custom-settings-page', 'wpautop' => true ) ); // Add help tab with custom callback WP_Contextual_Help::register_tab( 'custom-callback', 'Custom Callback Example', array( 'page' => array( 'post.php', 'post-new.php' ), 'post_type' => 'post', 'callback' => function( $screen, $tab ) { echo '<p>It is super easy to add new help tabs!</p>'; } ) ); } ); ?>
变更日志
请参阅完整的变更日志:https://github.com/voceconnect/wp-contextual-help/releases。