Working on help files
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 10 Jun 2019 20:52:20 +0000 (16:52 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 10 Jun 2019 20:52:20 +0000 (16:52 -0400)
Adding help menus

index.php
setup/help.php [new file with mode: 0644]
setup/help/dashboard.html [new file with mode: 0644]
setup/help/messages-list.html [new file with mode: 0644]

index e80fd81..b5653ef 100644 (file)
--- 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 (file)
index 0000000..bebd2e2
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+namespace glm\messages\help;
+
+/**
+ * Gaslight Media Members Billing Database
+ * GLM Billing Help
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersBillingDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @author   Steve Sutton <steve@gaslightmedia.com>
+ * @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 '<pre>$screen: ' . print_r( $screen, true ) . '</pre>';
+        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(
+            '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
+            '<p><a href="https://www.gaslightmedia.com/wp-admin-guide/#GLM" target="_blank">' .
+            __( 'Help Guide' ) . '</a></p>'
+        );
+    }
+);
diff --git a/setup/help/dashboard.html b/setup/help/dashboard.html
new file mode 100644 (file)
index 0000000..b6aec11
--- /dev/null
@@ -0,0 +1,10 @@
+<h2>Dashboard</h2>
+<p>This is your Messages dashboard</p>
+<p>From here you can view any Messages</p>
+<p>You can also
+<ul>
+    <li>List Email Message</li>
+    <li>Add Message</li>
+    <li>List Email Templates</li>
+    <li>Add Template</li>
+</ul></p>
diff --git a/setup/help/messages-list.html b/setup/help/messages-list.html
new file mode 100644 (file)
index 0000000..f7e3770
--- /dev/null
@@ -0,0 +1 @@
+Help