-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom-css.php
More file actions
48 lines (38 loc) · 1.39 KB
/
custom-css.php
File metadata and controls
48 lines (38 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
// Prevent direct access if not in WonderCMS
if (!defined('VERSION')) {
exit;
}
global $Wcms;
// Register listeners for custom CSS and settings
$Wcms->addListener('css', 'load_custom_css');
$Wcms->addListener('settings', 'custom_css_settings');
// Load custom CSS
function load_custom_css($args)
{
global $Wcms;
$custom_css_url = $Wcms->url('plugins/custom-css/custom.css');
// Add the custom CSS to the existing CSS in the head
$args[0] .= '<link rel="stylesheet" href="' . $custom_css_url . '" type="text/css">';
return $args;
}
// Display the custom CSS settings in the admin area
function custom_css_settings($args)
{
global $Wcms;
if (!$Wcms->loggedIn) return $args;
$args[0] .= "<div>Just a test</div>";
return $args;
// Load the current custom CSS content
$custom_css = file_get_contents('plugins/custom-css/custom.css');
if (isset($_POST['custom_css'])) {
// Save the custom CSS content to the file
file_put_contents('plugins/custom-css/custom.css', $_POST['custom_css']);
$custom_css = $_POST['custom_css']; // Update the variable with the new content
}
// Create the settings form
echo '<form method="post">';
echo '<textarea name="custom_css" style="width:100%; height:200px;">' . htmlspecialchars($custom_css) . '</textarea>';
echo '<button type="submit">Save Custom CSS</button>';
echo '</form>';
}