This repository contains the Knowledgebase Plugin, a WordPress plugin designed to add a knowledgebase functionality to your website. The plugin allows you to create, manage, and display a collection of knowledgebase articles using custom post types, shortcodes, and other dynamic features.
- Custom Post Types: Easily manage knowledgebase articles as custom post types.
- Shortcodes: Use shortcodes to display knowledgebase articles anywhere on your site.
- Settings Page: Customize plugin settings via an intuitive WordPress admin interface.
- Authentication Handlers: Secure your knowledgebase content with custom authentication logic.
- Styling: Predefined CSS styles for a polished appearance.
- Download the plugin files and extract them.
- Upload the
knowledgebase-pluginfolder to thewp-content/plugins/directory of your WordPress installation. - Activate the plugin via the WordPress Admin Dashboard under
Plugins > Installed Plugins.
- Navigate to the
Knowledgebasesection in the WordPress Admin Dashboard. - Add new articles by clicking on
Add New. - Use the provided fields to input the title, content, and metadata.
Use the shortcode [knowledgebase] to display a list of knowledgebase articles on any page or post.
knowledgebase-plugin/
├── knowledgebase-plugin.php
├── assets/
│ └── css/
│ └── styles.css
├── includes/
├── shortcodes.php
├── settings.php
├── auth-handlers.php
└── custom-post-type.php
-
knowledgebase-plugin.php:- The main plugin file.
- Registers all hooks and initializes the plugin.
-
assets/css/styles.css:- Contains styles for the knowledgebase pages and components.
-
includes/shortcodes.php:- Defines the
[knowledgebase]shortcode.
- Defines the
-
includes/settings.php:- Implements the settings page logic.
-
includes/auth-handlers.php:- Handles user authentication and content restrictions.
-
includes/custom-post-type.php:- Registers the custom post type for knowledgebase articles.
Below are the SQL commands required to set up the database tables for the Knowledgebase Plugin:
-- Table for storing knowledgebase articles
CREATE TABLE wp_knowledgebase_articles (
id BIGINT(20) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
content LONGTEXT NOT NULL,
author_id BIGINT(20) UNSIGNED NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME ON UPDATE CURRENT_TIMESTAMP,
status ENUM('published', 'draft', 'private') DEFAULT 'draft',
FOREIGN KEY (author_id) REFERENCES wp_users(ID) ON DELETE CASCADE
);
-- Table for article metadata (custom fields)
CREATE TABLE wp_knowledgebase_meta (
id BIGINT(20) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
article_id BIGINT(20) UNSIGNED NOT NULL,
meta_key VARCHAR(255) NOT NULL,
meta_value LONGTEXT,
FOREIGN KEY (article_id) REFERENCES wp_knowledgebase_articles(id) ON DELETE CASCADE
);
-- Table for storing categories
CREATE TABLE wp_knowledgebase_categories (
id BIGINT(20) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL UNIQUE,
description TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME ON UPDATE CURRENT_TIMESTAMP
);
-- Table for article-category relationships
CREATE TABLE wp_knowledgebase_article_category (
id BIGINT(20) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
article_id BIGINT(20) UNSIGNED NOT NULL,
category_id BIGINT(20) UNSIGNED NOT NULL,
FOREIGN KEY (article_id) REFERENCES wp_knowledgebase_articles(id) ON DELETE CASCADE,
FOREIGN KEY (category_id) REFERENCES wp_knowledgebase_categories(id) ON DELETE CASCADE
);
Notes: Replace the prefix wp_ with your actual database table prefix if it differs. These tables are designed to integrate seamlessly with WordPress conventions and practices.