First draft

This commit is contained in:
kim 2025-01-21 22:46:20 +01:00
commit f74ddfebf3
4 changed files with 84 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
wordpress-testing

1
assets/style.css Normal file
View file

@ -0,0 +1 @@
h1 { color: red; }

View file

@ -0,0 +1,18 @@
<?php
// Prevent direct access to the file
if (!defined('ABSPATH')) {
exit;
}
/**
* Render the content of the custom admin page.
*/
function kcw_render_admin_page() {
?>
<div class="wrap">
<h1><?php _e('Welcome to a KolliCloud Plugin Experiment', 'kcw'); ?></h1>
<p><?php _e('This is a custom admin interface example.', 'kcw'); ?></p>
<a href="<?php _e('https://login.local-it.org/', 'kcw') ?>" target="_blank"><?php _e('We coudl add also links here.', 'kcw'); ?></a>
</div>
<?php
}

64
wp-kolli-plugin.php Normal file
View file

@ -0,0 +1,64 @@
<?php
/**
* Plugin Name: WP Kollicloud Plugin
* Plugin URI: https://git.local-it.org/local-it/wp-kolli-plugin
* Description: a little bit of interface customization for Kollicloud.
* Version: 1.0
* Author: Local-IT
* Author URI: https://local-it.org
*/
// Prevent direct access to the file
if (!defined('ABSPATH')) {
exit;
}
// Include the custom kollicloud admin page template
require_once plugin_dir_path(__FILE__) . 'includes/views/kcw-overview.php';
/**
* Add a custom admin menu page.
*/
function kcw_add_admin_page() {
add_menu_page(
__('KolliCloud Dashboard', 'kcw'), // Page title
__('KolliCloud', 'kcw'), // Menu title
'manage_options', // Capability
'kolli-dash', // Menu slug
'kcw_render_admin_page', // Callback function
'dashicons-cloud', // Icon
1 // Position
);
/* Optional submenu for redirect experiments */
add_submenu_page(
'kolli-dash', // Parent slug
'Back2KolliCloud', // Page title
'Zurück zum Login', // Menu title
'manage_options', // Capability
'gokollihome', // Menu slug
'kcw_render_sub_page', // Callback function
);
}
add_action('admin_menu', 'kcw_add_admin_page');
function kcw_load_custom_wp_admin_style($hook) {
// Load only on ?page=sample-page not in sub menu
if( $hook != 'toplevel_page_kolli-dash') {
return;
}
wp_enqueue_style( 'custom_wp_admin_css', plugin_dir_url( __FILE__ ).'/assets/style.css' );
}
add_action( 'admin_enqueue_scripts', 'kcw_load_custom_wp_admin_style' );
/**
Custom redirect for kollicloud.de
*/
function redirect_from_admin_menu($value) {
global $pagenow;
if (isset($_GET['page']) && $_GET['page'] === 'gokollihome') {
wp_redirect("http://kollicloud.de"); // Change to your target page
exit;
}
}
add_action('after_setup_theme', 'redirect_from_admin_menu');