From 61615e64d39e9092b0120d770b5935cc240779c0 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 10 Jun 2019 16:52:20 -0400 Subject: [PATCH] Working on help files Adding help menus --- index.php | 5 ++ setup/help.php | 112 ++++++++++++++++++++++++++++++++++ setup/help/dashboard.html | 10 +++ setup/help/messages-list.html | 1 + 4 files changed, 128 insertions(+) create mode 100644 setup/help.php create mode 100644 setup/help/dashboard.html create mode 100644 setup/help/messages-list.html diff --git a/index.php b/index.php index e80fd81..b5653ef 100644 --- a/index.php +++ b/index.php @@ -117,6 +117,11 @@ if ($is_active != '1') { deactivate_plugins('/'.GLM_MEMBERS_MESSAGES_PLUGIN_SLUG.'/index.php'); } +/** + * Hooks for creating help documentation + */ +require_once GLM_MEMBERS_MESSAGES_PLUGIN_SETUP_PATH . '/help.php'; + // Check for Minimum DB version for main Member DB function glmMembersMessagesMinVerRequired() { echo ' diff --git a/setup/help.php b/setup/help.php new file mode 100644 index 0000000..bebd2e2 --- /dev/null +++ b/setup/help.php @@ -0,0 +1,112 @@ + + * @author Steve Sutton + * @license http://www.gaslightmedia.com Gaslightmedia + * @release help.php + * @link http://dev.gaslightmedia.com/ + */ + +/* + * Place Help Hooks and Filters here. If this file exists, it will be included + * by the Billing plugin script. + * + * Note that filter and hook callback functions must be included in-line as shown below... + * + * add_filter( 'filter_title', function( $parameter ) { + * // Function code + * }); + * + */ +function loadHelpFile( $screen, $tab ) +{ + $fileName = GLM_MEMBERS_MESSAGES_PLUGIN_SETUP_PATH . '/help/' . $tab['extra'] . '.html'; + if ( is_file( $fileName ) ) { + echo file_get_contents( $fileName ); + } else { + return false; + } +} + +add_action( 'current_screen', + function () { + $screen = get_current_screen(); + // var_dump($screen); + if ( !isset( $screen ) ) { + return false; + } + // echo '
$screen: ' . print_r( $screen, true ) . '
'; + if ( $screen->base != 'glm-associate_page_glm-members-admin-menu-messages' ) { + return false; + } + + $helpTabs = array( + array( + 'name' => 'dashboard', + 'title' => 'Dashboard', + 'subs' => array( + array( + 'name' => 'list', + 'title' => 'Email Messages', + ), + array( + 'name' => 'listTemplates', + 'title' => 'Email Templates', + ), + ), + ), + ); + + foreach ( $helpTabs as $tab ) { + $glmAction = isset( $_REQUEST['glm_action'] ) ? filter_var( $_REQUEST['glm_action'] ) : 'dashboard'; + if ( $glmAction === $tab['name'] ) { + $fileName = GLM_MEMBERS_BILLING_PLUGIN_SETUP_PATH . '/help/' . $tab['name'] . '.html'; + if ( is_file( $fileName ) ) { + $screen->add_help_tab( + array( + 'id' => 'glm-member-db-messages-help-' . $tab['name'], + 'title' => __( $tab['title'] ), + 'content' => '', + 'callback' => 'glm\messages\help\loadHelpFile', + 'extra' => $tab['name'], + ) + ); + } + $option = isset( $_REQUEST['option'] ) ? filter_var( $_REQUEST['option'] ) : 'dashboard'; + // Check for subs + if ( isset( $tab['subs'] ) && is_array( $tab['subs'] ) ) { + foreach ( $tab['subs'] as $sub ) { + $fileName = GLM_MEMBERS_BILLING_PLUGIN_SETUP_PATH . '/help/' . $option . '-' . $sub['name'] . '.html'; + if ( is_file( $fileName ) ) { + $screen->add_help_tab( + array( + 'id' => 'glm-member-db-messages-help-'. $option . '-' . $sub['name'], + 'title' => __( $sub['title'] ), + 'content' => '', + 'callback' => 'glm\messages\help\loadHelpFile', + 'extra' => $option . '-' . $sub['name'], + ) + ); + } + } + } + } + } + + // Help sidebars + $screen->set_help_sidebar( + '

' . __( 'For more information:' ) . '

' . + '

' . + __( 'Help Guide' ) . '

' + ); + } +); diff --git a/setup/help/dashboard.html b/setup/help/dashboard.html new file mode 100644 index 0000000..b6aec11 --- /dev/null +++ b/setup/help/dashboard.html @@ -0,0 +1,10 @@ +

Dashboard

+

This is your Messages dashboard

+

From here you can view any Messages

+

You can also +

diff --git a/setup/help/messages-list.html b/setup/help/messages-list.html new file mode 100644 index 0000000..f7e3770 --- /dev/null +++ b/setup/help/messages-list.html @@ -0,0 +1 @@ +Help -- 2.17.1