1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20:
21:
22: if ( !defined( 'ABSPATH' ) ) {
23: exit;
24: }
25:
26: 27: 28:
29: class Groups_Admin_Welcome {
30:
31: 32: 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: }
40:
41: 42: 43:
44: public static function admin_menu() {
45: add_dashboard_page(
46: __( 'Welcome to Groups', 'groups' ),
47: __( 'Welcome to Groups', 'groups' ),
48: 'manage_options',
49: 'groups-welcome',
50: array( __CLASS__, 'groups_welcome' )
51: );
52: }
53:
54: 55: 56:
57: public static function admin_head() {
58: remove_submenu_page( 'index.php', 'groups-welcome' );
59: }
60:
61: 62: 63:
64: public static function admin_init() {
65: global $groups_version;
66: if (
67: current_user_can( GROUPS_ACCESS_GROUPS ) &&
68: isset( $_GET['groups-welcome-dismiss'] ) &&
69: isset( $_GET['_groups_welcome_nonce'] )
70: ) {
71: if ( wp_verify_nonce( $_GET['_groups_welcome_nonce'], 'groups_welcome_dismiss' ) ) {
72: Groups_Options::update_user_option( 'groups-welcome-dismiss', $groups_version );
73: }
74: }
75: $groups_welcome_dismiss = Groups_Options::get_user_option( 'groups-welcome-dismiss', null );
76: if ( version_compare( $groups_version, $groups_welcome_dismiss ) > 0 ) {
77: if ( get_transient( 'groups_plugin_activated' ) || get_transient( 'groups_plugin_updated_legacy' ) ) {
78: $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
79: $doing_cron = defined( 'DOING_CRON' ) && DOING_CRON;
80:
81: if (
82: !$doing_ajax &&
83: !$doing_cron &&
84: ( empty( $_GET['page'] ) || $_GET['page'] !== 'groups-welcome' ) &&
85: !is_network_admin() &&
86: !isset( $_GET['activate-multi'] ) &&
87: current_user_can( GROUPS_ACCESS_GROUPS ) &&
88: apply_filters( 'groups_welcome_show', true )
89: ) {
90: wp_safe_redirect( admin_url( 'index.php?page=groups-welcome' ) );
91: exit;
92: }
93: }
94: }
95: }
96:
97: 98: 99: 100: 101: 102: 103:
104: public static function plugin_row_meta( $links, $file ) {
105: if ( $file == plugin_basename( GROUPS_FILE ) ) {
106: $row_meta = array(
107: 'welcome' => sprintf(
108: '<a href="%s" title="%s">%s</a>',
109: esc_url( admin_url( 'index.php?page=groups-welcome' ) ),
110: esc_attr( __( 'View the Welcome screen for this version of Groups', 'groups' ) ),
111: esc_html( __( 'Welcome', 'groups' ) )
112: )
113: );
114: return array_merge( $links, $row_meta );
115: }
116: return (array) $links;
117: }
118:
119: 120: 121:
122: public static function groups_welcome() {
123:
124: global $groups_version;
125:
126: wp_enqueue_style( 'groups_admin' );
127:
128: delete_transient( 'groups_plugin_activated' );
129: $legacy_update = get_transient( 'groups_plugin_updated_legacy' );
130: delete_transient( 'groups_plugin_updated_legacy' );
131:
132: echo '<div class="groups-welcome-panel">';
133: echo '<div class="groups-welcome-panel-content">';
134:
135: printf( '<img class="groups-welcome-icon" width="64" height="64" src="%s"/>', esc_attr( GROUPS_PLUGIN_URL . 'images/groups-256x256.png' ) );
136:
137: echo '<h1>';
138: printf( __( 'Welcome to Groups %s', 'groups' ), esc_html( $groups_version ) );
139: echo '</h1>';
140:
141: printf(
142: '<a class="notice-dismiss" href="%s" title="%s" aria-label="%s"></a>',
143: esc_url( wp_nonce_url( add_query_arg( 'groups-welcome-dismiss', '1', admin_url() ), 'groups_welcome_dismiss', '_groups_welcome_nonce' ) ),
144: esc_attr( __( 'Dismiss', 'groups' ) ),
145: esc_html( __( 'Dismiss', 'groups' ) )
146: );
147:
148: echo '<p class="headline">';
149: _e( 'Thanks for using Groups! We have made it even easier to protect your content and hope you like it :)', 'groups' );
150: echo '</p>';
151:
152: if ( $legacy_update ) {
153: echo '<p class="important">';
154: echo '<strong>';
155: _e( 'Important', 'groups' );
156: echo '</strong>';
157: echo '<br/><br/>';
158: _e( 'It seems that you have updated from Groups 1.x where access restrictions were based on capabilities.', 'groups' );
159: echo '<br/>';
160: printf( __( 'Please make sure to read the notes on <strong>Switching to Groups %s</strong> below.', 'groups' ), esc_html( $groups_version ) );
161: echo '</p>';
162: }
163:
164: echo '<h2>';
165: _e( "What's New?", 'groups' );
166: echo '</h2>';
167:
168: echo '<h3>';
169: _e( 'Protect Content Easily', 'groups' );
170: echo '</h3>';
171: echo '<p>';
172: _e( 'We have made it even easier to protect your content!', 'groups' );
173: echo ' ';
174: _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' );
175: echo ' ';
176: _e( 'Previously we used capabilities to do that, but changing to this new model makes things even easier.', 'groups' );
177: echo '</p>';
178:
179: echo '<h3>';
180: _e( 'Improved User Interface', 'groups' );
181: echo '</h3>';
182: echo '<p>';
183: _e( 'Now you can assign new users directly to groups when you create a new user account from the Dashboard.', 'groups' );
184: echo ' ';
185: _e( 'Another improvement is better filtering by groups and a reduced footprint on the Users admin screen.', 'groups' );
186: echo ' ';
187: _e( 'And you can now filter the list of users by one or multiple groups with one convenient field.', 'groups' );
188: echo '</p>';
189:
190: echo '<h3>';
191: _e( 'New Documentation', 'groups' );
192: echo '</h3>';
193: echo '<p>';
194: _e( 'Whether you are new to Groups or have been using it before, please make sure to visit the <a target="_blank" href="http://docs.itthinx.com/document/groups/">Documentation</a> pages to know more about how to use it.', 'groups' );
195: echo '</p>';
196:
197: $legacy_enabled = Groups_Options::get_option( GROUPS_LEGACY_ENABLE );
198: echo '<h2>';
199: printf( __( 'Switching to Groups %s', 'groups' ), esc_html( $groups_version ) );
200: echo '</h2>';
201: echo '<p>';
202: printf( __( 'Groups %s features a simpler model for access restrictions based on groups instead of capabilities used in previous versions.', 'groups' ), esc_html( $groups_version ) );
203: echo ' ';
204: _e( 'To put it simple, previously you would have used capabilities to restrict access to posts and now you simply use groups.', 'groups' );
205: echo ' ';
206: _e( 'To make it easier to transition to the new model for those who migrate from a previous version, we have included legacy access control based on capabilities.', 'groups' );
207: echo '</p>';
208: echo '<div class="indent">';
209: echo '<p>';
210: _e( 'The following is only of interest if you have upgraded from Groups 1.x:', 'groups' );
211: echo '<br/>';
212: if ( $legacy_enabled ) {
213: _e( 'You are running the system with legacy access control based on capabilities enabled.', 'groups' );
214: echo ' ';
215: _e( 'This means that if you had access restrictions in place that were based on capabilities, your entries will still be protected.', 'groups' );
216: } else {
217: _e( 'You are running the system with legacy access control based on capabilities disabled.', 'groups' );
218: echo ' ';
219: _e( 'This could be important!', 'groups' );
220: echo ' ';
221: _e( 'If you had any access restrictions in place based on capabilities, the entries will now be unprotected, unless you enable legacy access restrictions or place appropriate access restrictions based on groups on the desired entries.', 'groups' );
222: }
223: echo '</p>';
224: echo '<p>';
225: _e( 'If you would like to switch to access restrictions based on groups (recommended) instead of capabilities, you can easily do so by setting the appropriate groups on your protected posts, pages and other entries to restrict access.', 'groups' );
226: echo ' ';
227: _e( 'Once you have adjusted your access restrictions based on groups, you can disable legacy access control.', 'groups' );
228: echo ' ';
229: _e( 'Please refer to the <a target="_blank" href="http://docs.itthinx.com/document/groups/">Documentation</a> for details on how to switch to and use the new access restrictions.', 'groups' );
230: echo '</p>';
231: echo '</div>';
232:
233: echo '<h2>';
234: _e( 'Add-Ons', 'groups' );
235: echo '</h2>';
236: echo '<p>';
237: _e( 'Perfect complements to memberships and access control with Groups.', 'groups' );
238: echo '</p>';
239: echo '<div class="groups-admin-add-ons">';
240: groups_admin_add_ons_content( array( 'offset' => 1 ) );
241: echo '</div>';
242:
243: echo '</div>';
244: echo '</div>';
245: }
246: }
247: Groups_Admin_Welcome::init();
248: