Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Knowledge Space WP Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alg
Knowledge Space WP Plugin
Commits
9d8180d8
Commit
9d8180d8
authored
3 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
Summarised localize calls into one object
parent
e455f1eb
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
config.js
+2
-2
2 additions, 2 deletions
config.js
datasets/datasets.js
+3
-3
3 additions, 3 deletions
datasets/datasets.js
knowledge-space.php
+20
-21
20 additions, 21 deletions
knowledge-space.php
with
25 additions
and
26 deletions
config.js
+
2
−
2
View file @
9d8180d8
...
@@ -9,8 +9,8 @@ export const COLOR_PALETTE = [
...
@@ -9,8 +9,8 @@ export const COLOR_PALETTE = [
];
];
// Just renaming a variable which is given by the PHP script. This avoids errors in all other files.
// Just renaming a variable which is given by the PHP script. This avoids errors in all other files.
export
const
PLUGIN_PATH
=
plugin
.
path
;
export
const
PLUGIN_PATH
=
ks_global
.
plugin
_
path
;
export
var
SPACE
=
space
.
id
;
export
var
SPACE
=
ks_global
.
space
_
id
;
export
function
setSpace
(
space
)
{
export
function
setSpace
(
space
)
{
SPACE
=
space
;
SPACE
=
space
;
...
...
This diff is collapsed.
Click to expand it.
datasets/datasets.js
+
3
−
3
View file @
9d8180d8
...
@@ -17,7 +17,7 @@ export function loadGraphJson(spaceId) {
...
@@ -17,7 +17,7 @@ export function loadGraphJson(spaceId) {
return
jQuery
return
jQuery
.
ajax
({
.
ajax
({
type
:
"
POST
"
,
type
:
"
POST
"
,
url
:
ajax_object
.
ajax_url
,
url
:
ks_global
.
ajax_url
,
data
:
payload
,
data
:
payload
,
})
})
.
then
((
data
)
=>
JSON
.
parse
(
data
));
.
then
((
data
)
=>
JSON
.
parse
(
data
));
...
@@ -40,7 +40,7 @@ export function saveGraphJson(spaceId, json) {
...
@@ -40,7 +40,7 @@ export function saveGraphJson(spaceId, json) {
return
jQuery
.
ajax
({
return
jQuery
.
ajax
({
type
:
"
POST
"
,
type
:
"
POST
"
,
url
:
ajax_object
.
ajax_url
,
url
:
ks_global
.
ajax_url
,
data
:
payload
,
data
:
payload
,
});
});
}
}
...
@@ -57,7 +57,7 @@ export function listAllSpaces() {
...
@@ -57,7 +57,7 @@ export function listAllSpaces() {
return
jQuery
.
ajax
({
return
jQuery
.
ajax
({
type
:
"
POST
"
,
type
:
"
POST
"
,
url
:
ajax_object
.
ajax_url
,
url
:
ks_global
.
ajax_url
,
data
:
payload
,
data
:
payload
,
}).
then
((
data
)
=>
JSON
.
parse
(
data
)[
"
spaces
"
]);
}).
then
((
data
)
=>
JSON
.
parse
(
data
)[
"
spaces
"
]);
}
}
This diff is collapsed.
Click to expand it.
knowledge-space.php
+
20
−
21
View file @
9d8180d8
...
@@ -11,38 +11,42 @@ $GLOBALS['build'] = 'debug';
...
@@ -11,38 +11,42 @@ $GLOBALS['build'] = 'debug';
function
ks_add_graph
(
$atts
=
[]):
string
function
ks_add_graph
(
$atts
=
[]):
string
{
{
$space_id
=
kg_get_space_id_from_atts
(
$atts
);
$div
=
'<div id="3d-graph"></div>'
;
// The id "3d-graph" indicates, that the javascript associated with this should automatically be executed
$div
=
'<div id="3d-graph"></div>'
;
// The id "3d-graph" indicates, that the javascript associated with this should automatically be executed
$plugin_dir
=
plugin_dir_url
(
__FILE__
);
$script_path
=
'build'
.
DIRECTORY_SEPARATOR
.
$GLOBALS
[
'build'
]
.
DIRECTORY_SEPARATOR
.
'graph.js'
;
$script_path
=
'build'
.
DIRECTORY_SEPARATOR
.
$GLOBALS
[
'build'
]
.
DIRECTORY_SEPARATOR
.
'graph.js'
;
// $script = "<script src='$script_path'></script>";
// $script = "<script src='$script_path'></script>";
//wp_enqueue_script('kg-script', $script_path);
//wp_enqueue_script('kg-script', $script_path);
wp_enqueue_script
(
"ks-display-js"
,
plugins_url
(
$script_path
,
__FILE__
),
array
(
'jquery'
),
false
);
wp_enqueue_script
(
"ks-display-js"
,
plugins_url
(
$script_path
,
__FILE__
),
array
(
'jquery'
),
false
);
wp_localize_script
(
ks_localize
();
'ks-display-js'
,
'ajax_object'
,
array
(
'ajax_url'
=>
admin_url
(
'admin-ajax.php'
))
);
wp_localize_script
(
"ks-display-js"
,
"space"
,
array
(
'id'
=>
$space_id
));
wp_localize_script
(
"ks-display-js"
,
"plugin"
,
array
(
'path'
=>
$plugin_dir
));
return
$div
.
$variables
;
return
$div
;
// return $div . $variables . $script;
// return $div . $variables . $script;
}
}
function
ks_echo_graph
(
$atts
=
[]):
void
{
function
ks_echo_graph
(
$atts
=
[]):
void
{
echo
ks_add_graph
(
$atts
);
echo
ks_add_graph
(
$atts
);
}
}
function
ks_
add_editor
(
$atts
=
[]
)
function
ks_
localize
(
)
{
{
ks_add_editor_dependencies
();
$space_id
=
kg_get_space_id_from_atts
(
$atts
);
$space_id
=
kg_get_space_id_from_atts
(
$atts
);
$plugin_dir
=
plugin_dir_url
(
__FILE__
);
$plugin_dir
=
plugin_dir_url
(
__FILE__
);
wp_localize_script
(
"ks-editor-js"
,
"space"
,
array
(
'id'
=>
$space_id
));
wp_localize_script
(
wp_localize_script
(
"ks-editor-js"
,
"plugin"
,
array
(
'path'
=>
$plugin_dir
));
'ks-editor-js'
,
'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
();
require_once
(
__DIR__
.
'/editor/editor.php'
);
require_once
(
__DIR__
.
'/editor/editor.php'
);
}
}
...
@@ -55,11 +59,6 @@ function ks_add_editor_dependencies()
...
@@ -55,11 +59,6 @@ function ks_add_editor_dependencies()
wp_enqueue_script
(
"ks-editor-js"
,
plugins_url
(
$script_path
,
__FILE__
),
array
(
'jquery'
),
false
);
wp_enqueue_script
(
"ks-editor-js"
,
plugins_url
(
$script_path
,
__FILE__
),
array
(
'jquery'
),
false
);
//wp_register_script("ks-editor-js", plugins_url($script_path, __FILE__), array('jquery'), false);
//wp_register_script("ks-editor-js", plugins_url($script_path, __FILE__), array('jquery'), false);
wp_localize_script
(
'ks-editor-js'
,
'ajax_object'
,
array
(
'ajax_url'
=>
admin_url
(
'admin-ajax.php'
))
);
//wp_enqueue_script("ks-editor-js");
//wp_enqueue_script("ks-editor-js");
$style_file_version
=
date
(
"ymd-Gis"
,
filemtime
(
plugin_dir_path
(
__FILE__
)
.
"editor/css/editor.css"
));
$style_file_version
=
date
(
"ymd-Gis"
,
filemtime
(
plugin_dir_path
(
__FILE__
)
.
"editor/css/editor.css"
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment