64 lines
2.1 KiB
PHP
64 lines
2.1 KiB
PHP
<?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');
|
|
|