PluginProbe
Groups – Memberships and Access Control / 3.9.0
Groups – Memberships and Access Control v3.9.0
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 / admin / class-groups-admin-welcome.php

class-groups-admin-welcome.php in Groups – Memberships and Access Control 3.9.0, at lib/admin/class-groups-admin-welcome.php

245 lines 7.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * class-groups-admin-welcome.php
4 *
5 * Copyright (c) 2017 "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 2.0.0
20 */
21
22 if ( !defined( 'ABSPATH' ) ) {
23 exit;
24 }
25
26 /**
27 * Groups admin welcome and update screen.
28 */
29 class Groups_Admin_Welcome {
30
31 /**
32 * Adds actions to admin_menu, admin_head and admin_init.
33 */
34 public static function init() {
35 add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ) );
36 add_action( 'admin_head', array( __CLASS__, 'admin_head' ) );
37 add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
38 add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 );
39 add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
40 }
41
42 /**
43 * Adds the welcome screen to the dashboard menu.
44 */
45 public static function admin_menu() {
46 add_dashboard_page(
47 __( 'Welcome to Groups', 'groups' ),
48 __( 'Welcome to Groups', 'groups' ),
49 'manage_options',
50 'groups-welcome',
51 array( __CLASS__, 'groups_welcome' )
52 );
53 }
54
55 /**
56 * Removes the welcome screen from the dashboard menu.
57 */
58 public static function admin_head() {
59 remove_submenu_page( 'index.php', 'groups-welcome' );
60 }
61
62 /**
63 * Output admin notices.
64 *
65 * @since 3.3.1
66 */
67 public static function admin_notices() {
68 $is_updated_legacy = get_transient( 'groups_plugin_updated_legacy' );
69 if ( $is_updated_legacy ) {
70 $message = '<p>';
71 $message .= '<strong>';
72 $message .= esc_html__( 'Important', 'groups' );
73 $message .= '</strong>';
74 $message .= ' ';
75 $message .= esc_html__( 'It seems that you have updated from Groups 1.x where access restrictions were based on capabilities.', 'groups' );
76 $message .= '</p>';
77 $message .= '<p>';
78 $message .= sprintf(
79 /* translators: 1: opening tag 2: closing tag */
80 esc_html__( 'Please make sure to read the %1$sMigration Guide%2$s.', 'groups' ),
81 '<a href="https://docs.itthinx.com/document/groups/migration-guide/">',
82 '</a>'
83 );
84 $message .= '</p>';
85 wp_admin_notice(
86 $message,
87 array(
88 'type' => 'info',
89 'dismissible' => true,
90 'additional_classes' => array( 'inline', 'notice-alt' ),
91 'attributes' => array( 'data-slug' => 'plugin-slug' )
92 )
93 );
94 }
95 }
96
97 /**
98 * Checks if the welcome screen should be shown and redirected to.
99 */
100 public static function admin_init() {
101 global $groups_version;
102 if (
103 Groups_User::current_user_can( GROUPS_ACCESS_GROUPS ) &&
104 isset( $_GET['groups-welcome-dismiss'] ) &&
105 isset( $_GET['_groups_welcome_nonce'] )
106 ) {
107 if ( wp_verify_nonce( $_GET['_groups_welcome_nonce'], 'groups_welcome_dismiss' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
108 Groups_Options::update_user_option( 'groups-welcome-dismiss', $groups_version );
109 }
110 }
111 $groups_welcome_dismiss = Groups_Options::get_user_option( 'groups-welcome-dismiss', '' );
112 if ( version_compare( $groups_version, $groups_welcome_dismiss ) > 0 ) {
113 // @see Groups_Controller::activate()
114 if ( get_transient( 'groups_plugin_activated' ) ) {
115 $doing_ajax = wp_doing_ajax();
116 $doing_cron = wp_doing_cron();
117 // we'll delete the transients in the welcome screen handler
118 if (
119 !$doing_ajax &&
120 !$doing_cron &&
121 ( empty( $_GET['page'] ) || $_GET['page'] !== 'groups-welcome' ) &&
122 !is_network_admin() &&
123 Groups_User::current_user_can( GROUPS_ACCESS_GROUPS ) &&
124 apply_filters( 'groups_welcome_show', true )
125 ) {
126 wp_safe_redirect( admin_url( 'index.php?page=groups-welcome' ) );
127 exit;
128 } else {
129 // @since 3.3.1 remove the transient as we don't want to trigger a redirect in any other case than direct activation of the Groups plugin
130 delete_transient( 'groups_plugin_activated' );
131 }
132 }
133 }
134 }
135
136 /**
137 * Adds an entry leading to the welcome screen.
138 *
139 * @param array $links
140 * @param string $file plugin file basename
141 * @return array
142 */
143 public static function plugin_row_meta( $links, $file ) {
144 if ( $file == plugin_basename( GROUPS_FILE ) ) {
145 $row_meta = array(
146 'welcome' => sprintf(
147 '<a href="%s" title="%s">%s</a>',
148 esc_url( admin_url( 'index.php?page=groups-welcome' ) ),
149 esc_attr__( 'View the Welcome screen for this version of Groups', 'groups' ),
150 esc_html__( 'Welcome', 'groups' )
151 )
152 );
153 return array_merge( $links, $row_meta );
154 }
155 return (array) $links;
156 }
157
158 /**
159 * Renders the welcome screen.
160 */
161 public static function groups_welcome() {
162
163 global $groups_version;
164
165 wp_enqueue_style( 'groups_admin' );
166
167 delete_transient( 'groups_plugin_activated' );
168 // As of Groups 3.3.1 this transient does not trigger a redirect to the welcome screen.
169 // Instead, an admin notice pointing to the migration guide is displayed for as long as the transient has not expired.
170 // We still delete the transient here as we are displaying the welcome screen, and the notice will be visible on top of it.
171 delete_transient( 'groups_plugin_updated_legacy' );
172
173 echo '<div class="groups-welcome-panel">';
174 echo '<div class="groups-welcome-panel-content">';
175
176 echo '<div class="groups-welcome-panel-description">';
177
178 printf( '<img class="groups-welcome-icon" width="64" height="64" src="%s"/>', esc_attr( GROUPS_PLUGIN_URL . 'images/groups-256x256.png' ) );
179
180 echo '<h1>';
181 /* translators: version number */
182 printf( esc_html__( 'Welcome to Groups %s', 'groups' ), esc_html( $groups_version ) );
183 echo '</h1>';
184
185 printf(
186 '<a class="notice-dismiss" href="%s" title="%s" aria-label="%s"></a>',
187 esc_url( wp_nonce_url( add_query_arg( 'groups-welcome-dismiss', '1', admin_url() ), 'groups_welcome_dismiss', '_groups_welcome_nonce' ) ),
188 esc_attr__( 'Dismiss', 'groups' ),
189 esc_html__( 'Dismiss', 'groups' )
190 );
191
192 echo '<p class="headline">';
193 esc_html_e( 'Thanks for using Groups! We have made it even easier to protect your content and hope you like it :)', 'groups' );
194 echo '</p>';
195
196 echo '<h2>';
197 esc_html_e( "What's New?", 'groups' );
198 echo '</h2>';
199
200 echo '<h3>';
201 esc_html_e( 'Protect Content Easily', 'groups' );
202 echo '</h3>';
203 echo '<p>';
204 esc_html_e( 'We have made it even easier to protect your content!', 'groups' );
205 echo ' ';
206 esc_html_e( 'Now you can protect your posts, pages and any other custom post type like products or events by simply assigning them to one or more groups.', 'groups' );
207 echo '</p>';
208
209 echo '<h3>';
210 esc_html_e( 'Efficient User Interface', 'groups' );
211 echo '</h3>';
212 echo '<p>';
213 esc_html_e( 'Manage groups and users with a minimal footprint on the administrative screens.', 'groups' );
214 echo '</p>';
215
216 echo '<h3>';
217 esc_html_e( 'Documentation', 'groups' );
218 echo '</h3>';
219 echo '<p>';
220 printf(
221 /* translators: 1: opening tag, 2: closing tag */
222 esc_html__( 'Whether you are new to Groups or have been using it before, please make sure to visit the %1$sDocumentation%2$s pages to know more about how to use it.', 'groups' ),
223 '<a target="_blank" href="https://docs.itthinx.com/document/groups/">',
224 '</a>'
225 );
226 echo '</p>';
227
228 echo '</div>'; // .groups-welcome-panel-description
229
230 echo '<h2>';
231 esc_html_e( 'Add-Ons', 'groups' );
232 echo '</h2>';
233 echo '<p>';
234 esc_html_e( 'Perfect complements to memberships and access control with Groups.', 'groups' );
235 echo '</p>';
236 echo '<div class="groups-admin-add-ons">';
237 groups_admin_add_ons_content( array( 'offset' => 1 ) );
238 echo '</div>'; // .groups-admin-add-ons
239
240 echo '</div>'; // .groups-welcome-panel-content
241 echo '</div>'; // .groups-welcome-panel
242 }
243 }
244 Groups_Admin_Welcome::init();
245