100 lines
3.1 KiB
PHP
100 lines
3.1 KiB
PHP
<?php
|
|
/*
|
|
* Plugin Name: Kalifast bug reporter
|
|
* Plugin URI: https://kalifast.com/#/home
|
|
* Description: Add a button to report a bug on the website
|
|
* Version: 1.0
|
|
* Author: EISGE
|
|
* Author URI: https://kalifast.com/#/home
|
|
*/
|
|
|
|
|
|
/* EISGE Core plugin requirement */
|
|
|
|
require_once(ABSPATH.'wp-content/plugins/EISGE-API-Core/EISGE_Module_Core.php');
|
|
require_once(ABSPATH.'wp-content/plugins/Kalifast_Bug_Reporter/Reporter.php');
|
|
|
|
/* Register the module */
|
|
function install_kalifast_bug_reporter() {
|
|
$instance = new EISGE_Module_Core();
|
|
|
|
$instance->moduleInstall(array
|
|
(
|
|
'application' => 'eisge_api',
|
|
'module' => 'Kalifast_Bug_Reporter',
|
|
'module_desc' => 'A module to let the user create KALIFAST tickets',
|
|
'libraries' => array(
|
|
array(
|
|
"lib_name" => "Reporter",
|
|
"lib_desc" => "Contains the rest functions to report a bug on the website",
|
|
),
|
|
),
|
|
'modes' => array('DISPLAY', 'EDIT')
|
|
));
|
|
|
|
|
|
init_kalifast_bug_reporter_database();
|
|
|
|
}
|
|
|
|
/* Function to init database tables */
|
|
function init_kalifast_bug_reporter_database() {
|
|
// Open new PDO
|
|
$PDO = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASSWORD);
|
|
|
|
// Create the table API config
|
|
$PDO->exec('CREATE TABLE IF NOT EXISTS `kalifast_bug_reporter_config` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
`kft_api_host` varchar(255) NOT NULL,
|
|
`kft_api_key` varchar(255) NOT NULL,
|
|
PRIMARY KEY (`id`)
|
|
)');
|
|
|
|
// ticket config
|
|
$PDO->exec('CREATE TABLE IF NOT EXISTS `kalifast_bug_reporter_config_ticket` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
`ei_pool_id` varchar(255) NOT NULL,
|
|
`ei_delivery_id` varchar(255) NOT NULL,
|
|
`ei_user_id` varchar(255) NOT NULL,
|
|
PRIMARY KEY (`id`)
|
|
)');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
/* Function to uninstall database tables */
|
|
function uninstall_kalifast_bug_reporter_database() {
|
|
// Open new PDO
|
|
$PDO = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASSWORD);
|
|
|
|
// Drop the table
|
|
$PDO->exec('DROP TABLE IF EXISTS `kalifast_bug_reporter_config`');
|
|
$PDO->exec('DROP TABLE IF EXISTS `kalifast_bug_reporter_config_ticket`');
|
|
}
|
|
|
|
|
|
/* Unregister the module */
|
|
function uninstall_kalifast_bug_reporter() {
|
|
$instance = new EISGE_Module_Core();
|
|
$instance->moduleUninstall(array('application' => 'eisge_api', 'module'=>'Kalifast_Bug_Reporter'));
|
|
|
|
// uninstall_kalifast_bug_reporter_database();
|
|
}
|
|
|
|
/* Setup hooks */
|
|
add_action( 'activate_Kalifast_Bug_Reporter/module_setup.php', 'install_kalifast_bug_reporter' );
|
|
add_action( 'deactivate_Kalifast_Bug_Reporter/module_setup.php', 'uninstall_kalifast_bug_reporter' );
|
|
|
|
require_once(ABSPATH . '/wp-content/plugins/Kalifast_Bug_Reporter/config_menu.php');
|
|
|
|
|
|
|
|
function kft_ticket_form_shortcode() {
|
|
include dirname(__FILE__) . '/create_ticket_shortcode.php';
|
|
}
|
|
add_shortcode( 'KFT_TICKET_FORM', 'kft_ticket_form_shortcode');
|
|
Hyper Icon |