@@ -16,34 +16,70 @@ function __construct() {
1616 add_action ( 'admin_enqueue_scripts ' , array ( $ this , 'enqueue_dashboard_script ' ) );
1717
1818 add_action ( 'admin_init ' , array ( $ this , 'redirect_to_welcome_page ' ) );
19+ add_action ('admin_init ' , array ( $ this , 'redirect_to_docs ' ) );
20+
21+ add_action ('admin_head ' , array ( $ this , 'redirect_to_docs_newtab ' ) );
1922
2023 $ plugin = plugin_basename ( STACKABLE_FILE );
2124 add_filter ( 'plugin_action_links_ ' . $ plugin , array ( $ this , 'add_settings_link ' ) );
2225 }
2326
2427 public function add_dashboard_page () {
2528
26- // Our settings page.
27- add_submenu_page (
28- ' options-general.php ' , // Parent slug.
29+ $ icon = ' data:image/svg+xml;base64,PHN2ZyBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAyMDAgMjAwIiB2aWV3Qm94PSIwIDAgMjAwIDIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjZmZmIj48cGF0aCBkPSJtMTc2LjIgMjQuMmMtLjUtMS44LTIuMi0zLTQtMi44aC0xMDBsLTM5LjEgNDEuMmMtMi43IDIuNy0uOSA2LjQgMyA2LjRoODQuMWw1NC42LTQwLjZjMS4yLTEgMS44LTIuNiAxLjQtNC4yeiIvPjxwYXRoIGQ9Im0xNjcuMiAxMTUuNy0zOC40LTM3LjkuMS0uMWgtOTMuOGMtMS44IDAtMy4zIDEuNS0zLjMgMy4zIDAgLjkuNCAxLjcgMSAyLjNsMzguMiAzNy45LS4xLjFoOTQuMWMxLjgtLjEgMy4yLTEuNiAzLjItMy40IDAtLjgtLjQtMS42LTEtMi4yeiIvPjxwYXRoIGQ9Im0xNjcuMiAxMzEuMWMtLjctLjYtMS42LTEtMi41LTFoLTg0LjhsLTU0LjYgNDAuN2MtMS43IDEuMi0yLjEgMy42LS44IDUuNC44IDEuMSAyLjEgMS43IDMuNCAxLjZoMTAwbDM5LjUtNDEuNWMxLjItMS42IDEuMi0zLjktLjItNS4yeiIvPjwvZz48L3N2Zz4= ' ;
30+
31+ add_menu_page (
2932 __ ( 'Stackable ' , STACKABLE_I18N ), // Page title.
3033 __ ( 'Stackable ' , STACKABLE_I18N ) . ' ' . stackable_notification_count (), // Menu title.
3134 'manage_options ' , // Capability.
3235 'stackable ' , // Menu slug.
33- array ( $ this , 'stackable_settings_content ' ), // Callback function.
34- null // Position
36+ array ( $ this , 'stackable_getting_started_content ' ), // Callback function.
37+ $ icon ,
38+ 25
3539 );
3640
3741 // Our getting started page.
3842 add_submenu_page (
39- isset ( $ _GET [ ' page ' ] ) && $ _GET [ ' page ' ] === ' stackable-getting-started ' ? ' options-general.php ' : '' , // Parent slug. Only show when in the page .
40- __ ( 'Get Started ' , STACKABLE_I18N ), // Page title.
41- ' <span class="fs-submenu-item fs-sub"></span> ' . __ ( 'Get Started ' , STACKABLE_I18N ), // Menu title.
43+ ' stackable ' , // Parent slug.
44+ __ ( 'Getting Started ' , STACKABLE_I18N ), // Page title.
45+ __ ( 'Getting Started ' , STACKABLE_I18N ), // Menu title.
4246 'manage_options ' , // Capability.
43- 'stackable-getting-started ' , // Menu slug.
47+ 'stackable ' , // Menu slug.
4448 array ( $ this , 'stackable_getting_started_content ' ), // Callback function.
45- null // Position
4649 );
50+
51+ // Our settings page.
52+ add_submenu_page (
53+ 'stackable ' , // Parent slug.
54+ __ ( 'Stackable ' , STACKABLE_I18N ), // Page title.
55+ __ ( 'Settings ' , STACKABLE_I18N ) . ' ' . stackable_notification_count (), // Menu title.
56+ 'manage_options ' , // Capability.
57+ 'stackable-settings ' , // Menu slug.
58+ array ( $ this , 'stackable_settings_content ' ), // Callback function.
59+ );
60+
61+ do_action ( 'stackable_submenu_register ' );
62+
63+ // Documentation
64+ add_submenu_page (
65+ 'stackable ' , // Parent slug.
66+ __ ( 'Documentation ' , STACKABLE_I18N ), // Page title.
67+ __ ( 'Documentation ' , STACKABLE_I18N ), // Menu title.
68+ 'manage_options ' , // Capability.
69+ 'stackable-documentation ' , // Menu slug.
70+ '__return_null ' ,
71+ );
72+
73+ if ( STACKABLE_BUILD === 'free ' || ! sugb_fs ()->can_use_premium_code () ) {
74+ add_submenu_page (
75+ 'stackable ' , // Parent slug.
76+ __ ( 'Go Premium ' , STACKABLE_I18N ), // Page title.
77+ __ ( 'Go Premium ' , STACKABLE_I18N ), // Menu title.
78+ 'manage_options ' , // Capability.
79+ 'stackable-go-premium ' , // Menu slug.
80+ array ( $ this , 'stackable_go_premium_content ' ),
81+ );
82+ }
4783 }
4884
4985 public function enqueue_dashboard_script ( $ hook ) {
@@ -55,7 +91,7 @@ public function enqueue_dashboard_script( $hook ) {
5591 }
5692
5793 // For the options page, load our options script.
58- if ( 'settings_page_stackable ' === $ hook || stripos ( $ hook , 'page_stackable-settings ' ) !== false || 'settings_page_stackable-getting-started ' === $ hook ) {
94+ if ( 'settings_page_stackable ' === $ hook || stripos ( $ hook , 'page_stackable-settings ' ) !== false || 'toplevel_page_stackable ' === $ hook ) {
5995
6096 wp_enqueue_script ( 'wp-i18n ' );
6197 wp_enqueue_script ( 'wp-element ' );
@@ -95,7 +131,7 @@ public static function print_tabs() {
95131 $ display_account_tab = true ;
96132 $ display_contact_tab = true ;
97133 $ account_url = STACKABLE_BUILD === 'free ' ? '' : sugb_fs ()->get_account_url ();
98- $ contact_url = admin_url ( 'options-general .php?page=stackable-contact ' );
134+ $ contact_url = admin_url ( 'admin .php?page=stackable-contact ' );
99135
100136 // If network activated and in multisite, the accounts page is in a different URL.
101137 if ( STACKABLE_BUILD === 'free ' ) {
@@ -117,47 +153,54 @@ public static function print_tabs() {
117153
118154 ?>
119155 <div class="s-body s-tabs">
120- <a class="s-tab <?php echo $ screen ->base === 'settings_page_stackable-getting-started ' ? 's-active ' : '' ?> "
121- href="<?php echo admin_url ( 'options-general .php?page=stackable-getting-started ' ) ?> ">
156+ <a class="s-tab <?php echo $ screen ->base === 'toplevel_page_stackable ' ? 's-active ' : '' ?> "
157+ href="<?php echo admin_url ( 'admin .php?page=stackable ' ) ?> ">
122158 <span><?php _e ( 'Getting Started ' , STACKABLE_I18N ) ?> </span>
123159 </a>
124160
125- <a class="s-tab <?php echo $ screen ->base === 'settings_page_stackable ' ? 's-active ' : '' ?> "
126- href="<?php echo admin_url ( 'options-general .php?page=stackable ' ) ?> ">
161+ <a class="s-tab <?php echo $ screen ->base === 'stackable_page_stackable-settings ' ? 's-active ' : '' ?> "
162+ href="<?php echo admin_url ( 'admin .php?page=stackable-settings ' ) ?> ">
127163 <span><?php _e ( 'Settings ' , STACKABLE_I18N ) ?> </span>
128164 </a>
129165
130166 <?php if ( $ display_account_tab && STACKABLE_BUILD !== 'free ' && sugb_fs ()->get_user () ) { ?>
131- <a class="s-tab <?php echo $ screen ->base === 'settings_page_stackable -account ' ? 's-active ' : '' ?> "
167+ <a class="s-tab <?php echo $ screen ->base === 'stackable_page_stackable -account ' ? 's-active ' : '' ?> "
132168 href="<?php echo $ account_url ?> ">
133169 <span><?php _e ( 'Account ' , STACKABLE_I18N ) ?> </span>
134170 </a>
135171 <?php } ?>
136172
137173 <?php if ( STACKABLE_BUILD !== 'free ' && sugb_fs ()->has_affiliate_program () ) { ?>
138- <a class="s-tab <?php echo $ screen ->base === 'settings_page_stackable -affiliation ' ? 's-active ' : '' ?> "
174+ <a class="s-tab <?php echo $ screen ->base === 'stackable_page_stackable -affiliation ' ? 's-active ' : '' ?> "
139175 href="<?php echo admin_url ( 'options-general.php?page=stackable-affiliation ' ) ?> ">
140176 <span><?php _e ( 'Affiliation ' , STACKABLE_I18N ) ?> </span>
141177 </a>
142178 <?php } ?>
143179
180+ <?php if ( function_exists ( 'stackable_is_custom_fields_enabled ' ) ) { ?>
181+ <?php if ( stackable_is_custom_fields_enabled () && current_user_can ( 'manage_stackable_custom_fields ' ) ) { ?>
182+ <a class="s-tab <?php echo $ screen ->base === 'stackable_page_stk-custom-fields ' ? 's-active ' : '' ?> "
183+ href="<?php echo admin_url ( 'admin.php?page=stk-custom-fields ' ) ?> ">
184+ <span><?php _e ( 'Custom Fields ' , STACKABLE_I18N ) ?> </span>
185+ </a>
186+ <?php } ?>
187+ <?php } ?>
188+
144189 <a class="s-tab" href="https://docs.wpstackable.com" target="_docs">
145190 <span><?php _e ( 'Documentation ' , STACKABLE_I18N ) ?> </span></a>
146191
147192 <?php if ( $ display_contact_tab && STACKABLE_BUILD !== 'free ' ) { ?>
148- <a class="s-tab <?php echo $ screen ->base === 'settings_page_stackable -contact ' ? 's-active ' : '' ?> "
193+ <a class="s-tab <?php echo $ screen ->base === 'stackable_page_stackable -contact ' ? 's-active ' : '' ?> "
149194 href="<?php echo $ contact_url ?> ">
150195 <span><?php _e ( 'Contact Us ' , STACKABLE_I18N ) ?> </span>
151196 </a>
152197 <?php } ?>
153198
154- <?php if ( function_exists ( 'stackable_is_custom_fields_enabled ' ) ) { ?>
155- <?php if ( stackable_is_custom_fields_enabled () && current_user_can ( 'manage_stackable_custom_fields ' ) ) { ?>
156- <a class="s-tab <?php echo $ screen ->base === 'toplevel_page_stk-custom-fields ' ? 's-active ' : '' ?> "
157- href="<?php echo admin_url ( 'admin.php?page=stk-custom-fields ' ) ?> ">
158- <span><?php _e ( 'Custom Fields ' , STACKABLE_I18N ) ?> </span>
159- </a>
160- <?php } ?>
199+ <?php if ( STACKABLE_BUILD === 'free ' || ! sugb_fs ()->can_use_premium_code () ) { ?>
200+ <a class="s-tab <?php echo $ screen ->base === 'stackable_page_stackable-go-premium ' ? 's-active ' : '' ?> "
201+ href="<?php echo admin_url ( 'admin.php?page=stackable-go-premium ' )?> ">
202+ <span><?php _e ( 'Go Premium ' , STACKABLE_I18N ) ?> </span>
203+ </a>
161204 <?php } ?>
162205 </div>
163206 <?php
@@ -203,7 +246,27 @@ public function stackable_settings_content() {
203246 <div class="s-content" id="settings-content"></div>
204247 <?php do_action ( 'stackable_settings_page_mid ' ); ?>
205248 </div>
206- <!-- <div class="s-side">
249+ </section>
250+ </div>
251+ <?php
252+ }
253+
254+ public function stackable_go_premium_content () {
255+ ?>
256+ <div class="wrap wrap-settings">
257+ <div class="s-header-wrap s-header-settings">
258+ <?php $ this ->print_header () ?>
259+ <?php echo $ this ->print_premium_button () ?>
260+ <?php echo $ this ->print_tabs () ?>
261+ </div>
262+ <h1 aria-hidden="true" class="s-admin-notice-marker"></h1>
263+ <section id="settings-notice">
264+ <div class="s-rest-settings-notice"></div>
265+ <div class="s-save-settings-notice"></div>
266+ </section>
267+ <?php stackable_welcome_notification () ?>
268+ <section class="s-body-container s-body-container-with-sidenav">
269+ <div class="s-side">
207270 <?php if ( STACKABLE_BUILD === 'free ' || ! sugb_fs ()->can_use_premium_code () ) : ?>
208271 <aside class="s-box s-premium-box">
209272 <h3><?php _e ( '🚀 Stackable Premium ' , STACKABLE_I18N ) ?> </h3>
@@ -241,10 +304,7 @@ public function stackable_settings_content() {
241304 <p><?php _e ( 'Keep up to date by subscribing to our newsletter. ' , STACKABLE_I18N ) ?> </p>
242305 <p><a href="http://eepurl.com/dJY9xI" class="s-button" target="_new" title="<?php esc_attr_e ( 'Subscribe ' , STACKABLE_I18N ) ?> "><?php _e ( 'Subscribe ' , STACKABLE_I18N ) ?> </a></p>
243306 </aside>
244- </div> -->
245-
246-
247-
307+ </div>
248308 </section>
249309 </div>
250310 <?php
@@ -279,6 +339,31 @@ public function stackable_getting_started_content() {
279339 <?php
280340 }
281341
342+ /**
343+ * Redirect to the Stackable Documentation page.
344+ */
345+ public function redirect_to_docs () {
346+ if ( empty ( $ _GET ['page ' ] ) ) {
347+ return ;
348+ }
349+
350+ if ( 'stackable-documentation ' === $ _GET ['page ' ] ) {
351+ wp_redirect ('https://docs.wpstackable.com ' );
352+ exit ;
353+ }
354+ }
355+
356+ public function redirect_to_docs_newtab () {
357+ ?>
358+ <script>
359+ document.addEventListener('DOMContentLoaded', function() {
360+ const link = document.querySelector('a[href="admin.php?page=stackable-documentation"]');
361+ if (link) link.setAttribute('target', '_blank');
362+ });
363+ </script>
364+ <?php
365+ }
366+
282367 /**
283368 * Adds links to the plugins page entry.
284369 *
@@ -342,7 +427,7 @@ public function redirect_to_welcome_page() {
342427 }
343428
344429 // Or go to the getting started page.
345- wp_redirect ( esc_url ( admin_url ( 'options-general .php?page=stackable-getting-started ' ) ) );
430+ wp_redirect ( esc_url ( admin_url ( 'admin .php?page=stackable ' ) ) );
346431
347432 die ();
348433 }
0 commit comments