Newer
Older
<?php
/*
Plugin Name: Knowledge Space
Description: This plugin adds a knowledge space to the website via a shortcode.
Version: 1.0
Author: Matthias Konitzny
*/
$GLOBALS['build'] = 'debug';
function ks_add_graph($atts = []): string
$div = '<div id="3d-graph"></div>'; // The id "3d-graph" indicates, that the javascript associated with this should automatically be executed

Maximilian Giller
committed
$script_path = 'build' . DIRECTORY_SEPARATOR . $GLOBALS['build'] . DIRECTORY_SEPARATOR . 'graph.js';
wp_enqueue_script("ks-display-js", plugins_url($script_path, __FILE__), array('jquery'), false);

Maximilian Giller
committed
}
function ks_echo_graph($atts = []): void
{

Maximilian Giller
committed
{
$plugin_dir = plugin_dir_url(__FILE__);
'ks_global',
array(
'ajax_url' => admin_url('admin-ajax.php'),
'space_id' => $space_id,
'plugin_path' => $plugin_dir
)
);
}
function ks_add_editor($atts = [])
{
ks_add_editor_dependencies();
require_once(__DIR__ . '/editor/editor.php');
function ks_add_editor_dependencies()

Maximilian Giller
committed
{
$script_path = 'build' . DIRECTORY_SEPARATOR . $GLOBALS['build'] . DIRECTORY_SEPARATOR . 'graph.js';
wp_enqueue_script("ks-editor-js", plugins_url($script_path, __FILE__), array('jquery'), false);
$style_file_version = date("ymd-Gis", filemtime(plugin_dir_path(__FILE__) . "editor/css/editor.css"));
wp_enqueue_style("ks-editor-css", plugins_url("editor/css/editor.css", __FILE__), array(), $style_file_version);

Maximilian Giller
committed
}
function kg_load_css()
{
$plugin_dir = plugin_dir_url(__FILE__);
wp_enqueue_style('kg-style', $plugin_dir . 'kg-style.css');
{
return str_replace(
"\\",
"-",
str_replace(
"/",
"-",
str_replace(" ", "-", $id)
)
);
}

Maximilian Giller
committed
{
if ($atts != "" && array_key_exists("space", $atts)) {
} else {
return "space";
}
}
add_action('admin_menu', 'kg_editor_admin_add_page');
function kg_editor_admin_add_page()
{
add_menu_page(
'Knowledge Space',
'Knowledge Space',
'edit_plugins',
'knowledge-space',
'ks_echo_graph'
);
add_submenu_page(
'knowledge-space',
'Knowledge Space - Editor',
'Editor',
'edit_plugins',
'knowledge-space-editor',
'ks_add_editor'
);
}
require_once(__DIR__ . '/datasets/datasets.php');
add_action('wp_enqueue_scripts', 'kg_load_css');
add_shortcode('knowledge-space', 'ks_add_graph');
add_shortcode('knowledge-space-editor', 'ks_add_editor');