quiztech-assessment-platform/quiztech-assessment-platform.php

145 lines
No EOL
4.5 KiB
PHP

<?php
/**
* Plugin Name: Quiztech Assessment Platform
* Plugin URI: https://quiztech.com/
* Description: A platform for creating assessments, inviting applicants, and managing results.
* Version: 0.1.0
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Your Name / Company Name
* Author URI: https://yourwebsite.com/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: quiztech
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! \defined( 'WPINC' ) ) {
die;
}
/**
* Define constants
*/
\define( 'QUIZTECH_VERSION', '0.1.0' );
\define( 'QUIZTECH_PLUGIN_DIR', \plugin_dir_path( __FILE__ ) );
\define( 'QUIZTECH_PLUGIN_URL', \plugin_dir_url( __FILE__ ) );
\define( 'QUIZTECH_PLUGIN_FILE', __FILE__ );
/**
* Load Composer autoloader.
*/
require_once __DIR__ . '/vendor/autoload.php';
/**
* Load necessary procedural files not handled by PSR-4 autoloading.
*/
require_once QUIZTECH_PLUGIN_DIR . 'src/Includes/roles.php';
require_once QUIZTECH_PLUGIN_DIR . 'src/Includes/post-types.php';
require_once QUIZTECH_PLUGIN_DIR . 'src/Includes/taxonomies.php';
/**
* Load plugin dependencies. (Now handled by autoloading)
*/
// require_once QUIZTECH_PLUGIN_DIR . 'includes/post-types.php'; // Autoloaded
// require_once QUIZTECH_PLUGIN_DIR . 'includes/taxonomies.php'; // Autoloaded
// require_once QUIZTECH_PLUGIN_DIR . 'includes/roles.php'; // Autoloaded
/**
* The core plugin class that is used to define internationalization,
* admin-specific hooks, and public-facing site hooks.
*/
// require plugin_dir_path( __FILE__ ) . 'includes/class-quiztech.php';
/**
* Begins execution of the plugin.
*
* Since everything within the plugin is registered via hooks,
* then kicking off the plugin from this point in the file does
* not affect the page life cycle.
*
* @since 0.1.0
*/
function run_quiztech() {
// $plugin = new Quiztech();
// $plugin->run();
}
// run_quiztech();
// Placeholder for activation/deactivation hooks
\register_activation_hook( __FILE__, __NAMESPACE__ . '\activate_quiztech' );
\register_deactivation_hook( __FILE__, __NAMESPACE__ . '\deactivate_quiztech' );
/**
* The code that runs during plugin activation.
* This action is documented in includes/class-quiztech-activator.php
*/
function activate_quiztech() {
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
$table_name = $wpdb->prefix . 'quiztech_invitations';
$sql = "CREATE TABLE {$table_name} (
id mediumint(9) NOT NULL AUTO_INCREMENT,
token varchar(32) NOT NULL,
job_id bigint(20) unsigned NOT NULL,
assessment_id bigint(20) unsigned NOT NULL,
applicant_email varchar(255) NOT NULL,
status varchar(20) NOT NULL DEFAULT 'pending',
created_timestamp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
expiry_timestamp datetime DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY token (token),
KEY job_id (job_id),
KEY assessment_id (assessment_id),
KEY applicant_email (applicant_email(191)),
KEY status (status)
) {$charset_collate};";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
\dbDelta( $sql );
// Call the namespaced function for roles
\Quiztech\AssessmentPlatform\Includes\quiztech_add_roles_and_capabilities();
\flush_rewrite_rules(); // Ensure rewrite rules are updated for CPTs/taxonomies
}
/**
* The code that runs during plugin deactivation.
* This action is documented in includes/class-quiztech-deactivator.php
*/
function deactivate_quiztech() {
// Call the namespaced function
\Quiztech\AssessmentPlatform\Includes\quiztech_remove_roles_and_capabilities();
\flush_rewrite_rules(); // Clean up rewrite rules
}
/**
* Initialize the plugin's features.
*/
function quiztech_init() {
// Initialize frontend handler for invitation links
$frontend_handler = new \Quiztech\AssessmentPlatform\Includes\FrontendHandler();
$frontend_handler->init_hooks();
// Initialize AJAX handler for assessment interactions
\Quiztech\AssessmentPlatform\Includes\Ajax\AssessmentAjaxHandler::init();
// Initialize Admin-specific features
if ( is_admin() ) {
$admin_list_tables = new \Quiztech\AssessmentPlatform\Admin\AdminListTables();
$admin_list_tables->register_hooks();
$settings_page = new \Quiztech\AssessmentPlatform\Admin\SettingsPage();
$settings_page->register_hooks();
}
// TODO: Instantiate other core classes and call their init methods here
// e.g., Shortcode handlers etc.
}
add_action( 'plugins_loaded', 'quiztech_init' );
?>
?>