Skip to content

Commit 9c34e5c

Browse files
moved menu location
1 parent dd92aa8 commit 9c34e5c

3 files changed

Lines changed: 54 additions & 28 deletions

File tree

admin/menu.php

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,63 @@ function cache_everything_activate() {
1111
* Add an admin menu item for the plugin.
1212
*/
1313
function cache_everything_add_admin_menu() {
14-
// Settings Page
15-
add_menu_page(
16-
'Cache Everything Settings', // Page title
14+
add_submenu_page(
15+
'options-general.php', // Parent slug for Settings menu
16+
'Cache Everything', // Page title
1717
'Cache Everything', // Menu title
1818
'manage_options', // Capability
19-
'cache-everything-settings', // Menu slug for settings
20-
'cache_everything_settings_page', // Function to display the settings page
21-
'dashicons-cloud', // Icon URL
22-
6 // Position
19+
'cache-everything', // Menu slug
20+
'cache_everything_settings_wrapper_page' // Function to display the wrapper settings page
2321
);
2422

25-
add_submenu_page(
26-
'cache-everything-settings', // Parent slug
27-
'Available CSS Classes', // Page title
28-
'CSS Classes', // Menu title
29-
'manage_options', // Capability
30-
'cache-everything-css-classes', // Menu slug for CSS Classes
31-
'cache_everything_display_css_classes' // Function to display the CSS Classes page
32-
);
23+
add_action('admin_init', 'cache_everything_register_settings');
24+
}
3325

34-
// Readme Page
35-
add_submenu_page(
36-
'cache-everything-settings', // Parent slug
37-
'Cache Everything Readme', // Page title
38-
'Readme', // Menu title
39-
'manage_options', // Capability
40-
'cache-everything-readme', // Menu slug for readme
41-
'cache_everything_display_readme' // Function to display the readme page
26+
add_action('admin_menu', 'cache_everything_add_admin_menu');
27+
28+
function cache_everything_admin_tabs( $current = 'settings' ) {
29+
// Display the plugin title and version
30+
echo '<h1>Cache Everything v' . CACHE_EVERYTHING_VERSION . '</h1>';
31+
32+
$tabs = array(
33+
'settings' => 'Settings',
34+
'css_classes' => 'CSS Classes',
35+
'readme' => 'Readme'
4236
);
37+
echo '<h2 class="nav-tab-wrapper">';
38+
foreach( $tabs as $tab => $name ){
39+
$class = ( $tab == $current ) ? ' nav-tab-active' : '';
40+
echo "<a class='nav-tab$class' href='?page=cache-everything&tab=$tab'>$name</a>";
41+
}
42+
echo '</h2>';
43+
}
4344

44-
add_action('admin_init', 'cache_everything_register_settings');
45+
function cache_everything_settings_wrapper_page() {
46+
// Determine the current tab. Default to 'settings' if not set.
47+
$current_tab = isset($_GET['tab']) ? $_GET['tab'] : 'settings';
48+
49+
// Output the tabs
50+
cache_everything_admin_tabs($current_tab);
51+
52+
// Switch to determine which content to load based on the current tab
53+
switch ($current_tab) {
54+
case 'settings':
55+
cache_everything_settings_page();
56+
break;
57+
case 'css_classes':
58+
cache_everything_display_css_classes();
59+
break;
60+
case 'readme':
61+
cache_everything_display_readme();
62+
break;
63+
default:
64+
cache_everything_settings_page(); // Default to settings if the tab is unrecognized
65+
break;
66+
}
4567
}
4668

47-
add_action('admin_menu', 'cache_everything_add_admin_menu');
69+
function cache_everything_enqueue_admin_styles() {
70+
wp_enqueue_style('wp-admin');
71+
}
72+
73+
add_action('admin_enqueue_scripts', 'cache_everything_enqueue_admin_styles');

cache-everything.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
* Plugin Name: Cache Everything
44
* Plugin URI: https://github.com/AsyncAlchemist
55
* Description: A simple plugin to cache everything in Wordpress.
6-
* Version: 0.21
6+
* Version: 0.22
77
* Author: Taylor Selden
88
* Author URI: https://github.com/AsyncAlchemist
99
*/
1010
define('CACHE_EVERYTHING_JS_URL', 'wp-content/plugins/cache-everything/js');
1111
define('CACHE_EVERYTHING_CSS_URL', 'wp-content/plugins/cache-everything/css');
12-
define('CACHE_EVERYTHING_VERSION', '0.21');
12+
define('CACHE_EVERYTHING_VERSION', '0.22');
1313

1414
require_once(plugin_dir_path(__FILE__) . 'handle-js-request.php');
1515
require_once(plugin_dir_path(__FILE__) . 'handle-css-request.php');

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Cache Everything Plugin
1+
# Cache Everything Wordpress Plugin
22

33
The Cache Everything plugin is designed to enhance the performance of WordPress sites by caching dynamic aspects of the site, including HTML for logged-in users. This plugin dynamically generates CSS and JavaScript based on user roles, ensuring that cached content is personalized and up-to-date.
44

0 commit comments

Comments
 (0)