<?php /* Plugin Name: Knowledge Space Description: This plugin adds a knowledge space to the website via a shortcode. Version: 1.0 Author: Matthias Konitzny */ function ks_add_graph(): string { $graph = '<script src="//unpkg.com/3d-force-graph"></script>'; $div = '<div id="3d-graph"></div>'; $plugin_dir = plugin_dir_url(__FILE__); $dataset = $plugin_dir.'datasets/miserables.json'; $variables = "<script> var dataset = '$dataset'; </script>"; $script_path = $plugin_dir.'graph.js'; $script = "<script src='$script_path'></script>"; return $graph . $div . $variables . $script; } add_shortcode('knowledge-space', 'ks_add_graph');