PluginProbe
Groups – Memberships and Access Control / 1.10.1
Groups – Memberships and Access Control v1.10.1
4.7.1 4.7.0 4.6.0 4.5.0 4.4.0 4.3.0 trunk 1.0.0-beta-1 1.0.0-beta-2 1.0.0-beta-3 1.0.0-beta-3b 1.0.0-beta-3c 1.0.0-beta-3d 1.1.4 1.1.5 1.10.0 1.10.1 1.10.2 1.10.3 1.11.0 1.11.1 1.11.2 1.11.3 1.12.0 1.13.0 All 131 releases
groups / lib / core / class-groups-help.php

class-groups-help.php in Groups – Memberships and Access Control 1.10.1, at lib/core/class-groups-help.php

157 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * class-groups-help.php
4 *
5 * Copyright (c) "kento" Karim Rahimpur www.itthinx.com
6 *
7 * This code is released under the GNU General Public License.
8 * See COPYRIGHT.txt and LICENSE.txt.
9 *
10 * This code is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * This header and all notices must be kept intact.
16 *
17 * @author Karim Rahimpur
18 * @package groups
19 * @since groups 1.0.0
20 */
21
22 if ( !defined( 'ABSPATH' ) ) {
23 exit;
24 }
25
26 /**
27 * Help renderer.
28 */
29 class Groups_Help {
30
31 /**
32 * Help setup.
33 */
34 public static function init() {
35 add_action( 'groups_admin_menu', array( __CLASS__, 'groups_admin_menu' ) );
36 // @todo temporary fix for GFA <= 1.0.11 on localized installations - can be removed when all are updated
37 if ( defined( 'GFA_VIEWS_LIB' ) ) {
38 if ( file_exists( GFA_VIEWS_LIB . '/class-gfa-help.php' ) ) {
39 include_once( GFA_VIEWS_LIB . '/class-gfa-help.php' );
40 }
41 }
42
43 add_filter( 'admin_footer_text', array( __CLASS__, 'admin_footer_text' ) );
44 }
45
46 /**
47 * Adds contextual help to Groups admin screens.
48 *
49 * @param array $pages admin pages
50 */
51 public static function groups_admin_menu( $pages ) {
52 foreach ( $pages as $page ) {
53 add_action( 'load-' . $page, array( __CLASS__, 'contextual_help' ) );
54 }
55 }
56
57 /**
58 * Adds help to an admin screen.
59 */
60 public static function contextual_help() {
61 if ( $screen = get_current_screen() ) {
62 $show_groups_help = false;
63 $help_title = __( 'Groups', GROUPS_PLUGIN_DOMAIN );
64 $screen_id = $screen->base;
65 // The prefix of the $screen_id is translated, use only the suffix
66 // to identify a screen:
67 $ids = array(
68 'groups-admin' => __( 'Groups', GROUPS_PLUGIN_DOMAIN ),
69 'groups-admin-groups' => __( 'Groups', GROUPS_PLUGIN_DOMAIN ),
70 'groups-admin-options' => __( 'Options', GROUPS_PLUGIN_DOMAIN ),
71 'groups-admin-capabilities' => __( 'Capabilities', GROUPS_PLUGIN_DOMAIN ),
72 );
73 foreach ( $ids as $id => $title ) {
74 $i = strpos( $screen_id, $id );
75 if ( $i !== false ) {
76 if ( $i + strlen( $id ) == strlen( $screen_id ) ) {
77 $screen_id = $id;
78 $show_groups_help = true;
79 $help_title = $title;
80 break;
81 }
82 }
83 }
84 if ( $show_groups_help ) {
85 $help = '<h3><a href="http://www.itthinx.com/plugins/groups" target="_blank">'. $help_title .'</a></h3>';
86 $help .= '<p>';
87 $help .= __( 'The complete documentation is available on the <a href="http://docs.itthinx.com/document/groups">Documentation</a> pages for Groups.', GROUPS_PLUGIN_DOMAIN );
88 $help .= '</p>';
89 switch ( $screen_id ) {
90 case 'groups-admin' :
91 case 'groups-admin-groups':
92 $help .= '<p>' . __( 'Here you can <strong>add</strong>, <strong>edit</strong> and <strong>remove</strong> groups.', GROUPS_PLUGIN_DOMAIN ) . '</p>';
93 break;
94 case 'groups-admin-options' :
95 case 'groups-admin-capabilities' :
96 break;
97 }
98
99 $screen->add_help_tab(
100 array(
101 'id' => $screen_id,
102 'title' => $help_title,
103 'content' => $help
104 )
105 );
106 }
107 }
108 }
109
110 /**
111 * Provides the footer text for Groups on relevant screens.
112 *
113 * @param string $footer_text
114 * @return mixed
115 */
116 public static function admin_footer_text( $text ) {
117 if ( function_exists( 'get_current_screen' ) ) {
118 $current_screen = get_current_screen();
119 if (
120 isset( $current_screen->id ) &&
121 (
122 stripos( $current_screen->id, 'groups-' ) === 0 ||
123 stripos( $current_screen->id, 'groups_' ) === 0 ||
124 stripos( $current_screen->id, 'toplevel_page_groups' ) === 0
125 )
126 ) {
127 $text = self::footer( false );
128 }
129 }
130 return $text;
131 }
132
133 /**
134 * Returns or renders the footer.
135 *
136 * @param boolean $render
137 */
138 public static function footer( $render = true ) {
139 $footer =
140 '<span class="groups-footer">' .
141 __( 'Thank you for using <a href="http://www.itthinx.com/plugins/groups" target="_blank">Groups</a> by <a href="http://www.itthinx.com" target="_blank">itthinx</a>.', GROUPS_PLUGIN_DOMAIN ) .
142 ' ' .
143 sprintf(
144 __( 'Please give it a <a href="%s">&#9733;&#9733;&#9733;&#9733;&#9733;</a> rating.', GROUPS_PLUGIN_DOMAIN ),
145 esc_attr( 'http://wordpress.org/support/view/plugin-reviews/groups?filter=5#postform' )
146 ) .
147 '</span>';
148 $footer = apply_filters( 'groups_footer', $footer );
149 if ( $render ) {
150 echo $footer;
151 } else {
152 return $footer;
153 }
154 }
155 }
156 Groups_Help::init();
157