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
65618b2b
Commit
65618b2b
authored
3 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
First database setup
parent
70913b73
No related branches found
No related tags found
No related merge requests found
Pipeline
#53539
passed
3 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
knowledge-space-database.php
+99
-0
99 additions, 0 deletions
knowledge-space-database.php
knowledge-space.php
+1
-0
1 addition, 0 deletions
knowledge-space.php
with
100 additions
and
0 deletions
knowledge-space-database.php
0 → 100644
+
99
−
0
View file @
65618b2b
<?php
$SPACES_TABLE
=
get_table_name
(
"spaces"
);
$NODES_TABLE
=
get_table_name
(
"nodes"
);
$NODETYPES_TABLE
=
get_table_name
(
"nodetypes"
);
$LINKS_TABLE
=
get_table_name
(
"links"
);
$REFERENCES_TABLE
=
get_table_name
(
"references"
);
global
$ks_db_version
;
$ks_db_version
=
'1.0'
;
function
get_table_name
(
$table
)
{
global
$wpdb
;
return
$wpdb
->
prefix
.
"ks_"
.
$table
;
}
register_activation_hook
(
__FILE__
,
'ks_install'
);
function
ks_install
()
{
global
$wpdb
;
global
$ks_db_version
;
$installed_ver
=
get_option
(
"ks_db_version"
);
if
(
$installed_ver
==
$ks_db_version
)
{
return
;
}
$charset_collate
=
$wpdb
->
get_charset_collate
();
require_once
(
__DIR__
.
'/../../../wp-admin/includes/upgrade.php'
);
global
$SPACES_TABLE
;
$sql
=
"CREATE TABLE
$SPACES_TABLE
(
space_id int(11) NOT NULL AUTO_INCREMENT,
name text NOT NULL,
description text NOT NULL,
PRIMARY KEY (space_id)
)
$charset_collate
;"
;
dbDelta
(
$sql
);
//! Has some weird restrictions for the SQL Query: https://codex.wordpress.org/Creating_Tables_with_Plugins
global
$NODETYPES_TABLE
;
$sql
=
"CREATE TABLE
$NODETYPES_TABLE
(
nodetype_id int(11) NOT NULL AUTO_INCREMENT,
name text NOT NULL,
color bit(24) NOT NULL,
PRIMARY KEY (nodetype_id)
)
$charset_collate
;"
;
dbDelta
(
$sql
);
//! Has some weird restrictions for the SQL Query: https://codex.wordpress.org/Creating_Tables_with_Plugins
global
$NODES_TABLE
;
$sql
=
"CREATE TABLE
$NODES_TABLE
(
node_id int(11) NOT NULL AUTO_INCREMENT,
title text NOT NULL,
description text NOT NULL,
icon_url text,
header_url text,
video_url text,
nodetype_id int(11) NOT NULL,
space_id int(11) NOT NULL,
PRIMARY KEY (node_id)
)
$charset_collate
;"
;
dbDelta
(
$sql
);
//! Has some weird restrictions for the SQL Query: https://codex.wordpress.org/Creating_Tables_with_Plugins
global
$LINKS_TABLE
;
$sql
=
"CREATE TABLE
$LINKS_TABLE
(
link_id int(11) NOT NULL AUTO_INCREMENT,
source_node_id int(11) NOT NULL,
target_node_id int(11) NOT NULL,
PRIMARY KEY (link_id)
)
$charset_collate
;"
;
dbDelta
(
$sql
);
//! Has some weird restrictions for the SQL Query: https://codex.wordpress.org/Creating_Tables_with_Plugins
global
$REFERENCES_TABLE
;
$sql
=
"CREATE TABLE
$REFERENCES_TABLE
(
reference_id int(11) NOT NULL AUTO_INCREMENT,
url text NOT NULL,
node_id int(11) NOT NULL,
PRIMARY KEY (reference_id)
)
$charset_collate
;"
;
dbDelta
(
$sql
);
//! Has some weird restrictions for the SQL Query: https://codex.wordpress.org/Creating_Tables_with_Plugins
add_option
(
'ks_db_version'
,
$ks_db_version
);
}
// Handling upgrade
function
ks_update_db_check
()
{
global
$ks_db_version
;
if
(
get_site_option
(
'ks_db_version'
)
!=
$ks_db_version
)
{
ks_install
();
}
}
add_action
(
'plugins_loaded'
,
'ks_update_db_check'
);
This diff is collapsed.
Click to expand it.
knowledge-space.php
+
1
−
0
View file @
65618b2b
...
@@ -123,6 +123,7 @@ function kg_editor_admin_add_page()
...
@@ -123,6 +123,7 @@ function kg_editor_admin_add_page()
}
}
require_once
(
__DIR__
.
"/knowledge-space-database.php"
);
require_once
(
__DIR__
.
'/datasets/datasets.php'
);
require_once
(
__DIR__
.
'/datasets/datasets.php'
);
//add_action('wp_enqueue_scripts', 'kg_load_css');
//add_action('wp_enqueue_scripts', 'kg_load_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