-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpressprimer-quiz.php
More file actions
118 lines (108 loc) · 3.56 KB
/
pressprimer-quiz.php
File metadata and controls
118 lines (108 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
* Plugin Name: PressPrimer Quiz
* Plugin URI: https://pressprimer.com/quiz
* Description: Enterprise-grade quiz and assessment platform for WordPress educators.
* Version: 2.2.0
* Requires at least: 6.4
* Requires PHP: 7.4
* Author: PressPrimer
* Author URI: https://pressprimer.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: pressprimer-quiz
* Domain Path: /languages
*
* @package PressPrimer_Quiz
* @since 1.0.0
*/
// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Plugin constants
define( 'PRESSPRIMER_QUIZ_VERSION', '2.2.0' );
define( 'PRESSPRIMER_QUIZ_PLUGIN_FILE', __FILE__ );
define( 'PRESSPRIMER_QUIZ_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
define( 'PRESSPRIMER_QUIZ_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'PRESSPRIMER_QUIZ_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
define( 'PRESSPRIMER_QUIZ_DB_VERSION', '2.2.3' );
// Composer autoloader (for smalot/pdfparser and other vendor dependencies)
if ( file_exists( PRESSPRIMER_QUIZ_PLUGIN_PATH . 'vendor/autoload.php' ) ) {
require_once PRESSPRIMER_QUIZ_PLUGIN_PATH . 'vendor/autoload.php';
}
// Autoloader
require_once PRESSPRIMER_QUIZ_PLUGIN_PATH . 'includes/class-ppq-autoloader.php';
PressPrimer_Quiz_Autoloader::register();
// Activation/Deactivation hooks
register_activation_hook( __FILE__, [ 'PressPrimer_Quiz_Activator', 'activate' ] );
register_deactivation_hook( __FILE__, [ 'PressPrimer_Quiz_Deactivator', 'deactivate' ] );
// Multisite: Hook for new site creation to set up tables
add_action( 'wp_initialize_site', [ 'PressPrimer_Quiz_Activator', 'activate_new_site' ], 10, 1 );
/**
* Initialize plugin
*
* Initializes the main plugin class.
* Hooked to 'init' to comply with WordPress 6.7+ translation loading requirements.
*
* @since 1.0.0
*/
function pressprimer_quiz_init() {
// Initialize main plugin class
$plugin = PressPrimer_Quiz_Plugin::get_instance();
$plugin->run();
}
add_action( 'init', 'pressprimer_quiz_init', 0 );
/**
* Get the addon manager instance
*
* Returns the singleton instance of the addon manager for addon registration
* and compatibility checking.
*
* @since 2.0.0
*
* @return PressPrimer_Quiz_Addon_Manager The addon manager instance.
*/
function pressprimer_quiz_addon_manager() {
return PressPrimer_Quiz_Addon_Manager::get_instance();
}
/**
* Register a premium addon
*
* Helper function for addons to register themselves with the addon manager.
*
* Example usage:
* ```php
* add_action( 'pressprimer_quiz_register_addons', function() {
* pressprimer_quiz_register_addon( 'ppq-educator', [
* 'name' => 'PressPrimer Quiz Educator',
* 'version' => '1.0.0',
* 'file' => __FILE__,
* 'requires' => '2.0.0',
* 'tier' => 'educator',
* ] );
* } );
* ```
*
* @since 2.0.0
*
* @param string $slug Unique addon identifier.
* @param array $config Addon configuration array.
* @return bool True on success, false if already registered.
*/
function pressprimer_quiz_register_addon( $slug, $config ) {
return pressprimer_quiz_addon_manager()->register( $slug, $config );
}
/**
* Check if a premium addon is active
*
* Use this to conditionally enable features that depend on premium addons.
*
* @since 2.0.0
*
* @param string $slug Addon slug to check.
* @return bool True if addon is registered and compatible.
*/
function pressprimer_quiz_addon_active( $slug ) {
return pressprimer_quiz_addon_manager()->is_active( $slug );
}