Newer
Older
<?php
/*
Plugin Name: Knowledge Space
Description: A Wordpress-Plugin to display knowledge in a graph-structured way.
Author: Matthias Konitzny, Maximilian Giller, Joscha Rode
$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';

Maximilian Giller
committed
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();
ks_localize("ks-editor-js", $atts);
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);

Maximilian Giller
committed
}
function ks_load_styles() {
$styles_path = 'build' . DIRECTORY_SEPARATOR . $GLOBALS['build'] . DIRECTORY_SEPARATOR . 'graph.css';
wp_enqueue_style('ks-style', plugins_url($styles_path, __FILE__));
{
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');