-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodel-context-polytechnic.php
More file actions
77 lines (68 loc) · 3.06 KB
/
model-context-polytechnic.php
File metadata and controls
77 lines (68 loc) · 3.06 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
<?php
/**
* Plugin Name: Model Context Polytechnic
* Description: A public MCP learning and diagnostics server for WordPress.
* Version: 1.0.15
* Requires PHP: 8.1
* Requires at least: 6.9
* Author: Nick
* Text Domain: model-context-polytechnic
*/
defined( 'ABSPATH' ) || exit;
define( 'MODEL_CONTEXT_POLYTECHNIC_VERSION', '1.0.15' );
define( 'MODEL_CONTEXT_POLYTECHNIC_FILE', __FILE__ );
define( 'MODEL_CONTEXT_POLYTECHNIC_DIR', __DIR__ );
// Use Jetpack Autoloader so multiple plugins using mcp-adapter do not clash.
$model_context_polytechnic_autoloader = __DIR__ . '/vendor/autoload_packages.php';
if ( ! file_exists( $model_context_polytechnic_autoloader ) ) {
add_action(
'admin_notices',
static function () {
echo '<div class="notice notice-error"><p><strong>Model Context Polytechnic</strong>: run <code>composer install</code> in the plugin directory.</p></div>';
}
);
return;
}
require_once $model_context_polytechnic_autoloader;
require_once __DIR__ . '/includes/class-server.php';
require_once __DIR__ . '/includes/class-auth.php';
require_once __DIR__ . '/includes/class-public-session.php';
require_once __DIR__ . '/includes/class-registry.php';
require_once __DIR__ . '/includes/class-learning.php';
require_once __DIR__ . '/includes/class-course-pack.php';
require_once __DIR__ . '/includes/class-bundled-courses.php';
require_once __DIR__ . '/includes/class-feedback-cli.php';
require_once __DIR__ . '/includes/class-rewrite.php';
add_filter( 'mcp_adapter_create_default_server', '__return_false' );
add_action( 'wp_abilities_api_categories_init', [ 'ModelContextPolytechnic\\Mcp\\Server', 'register_ability_category' ] );
// Auto-load every ability file.
foreach ( glob( __DIR__ . '/includes/abilities/*.php' ) as $model_context_polytechnic_file ) {
require_once $model_context_polytechnic_file;
}
add_action( 'plugins_loaded', [ 'ModelContextPolytechnic\\Mcp\\Server', 'init' ] );
add_action( 'plugins_loaded', [ 'ModelContextPolytechnic\\Mcp\\Auth', 'init' ] );
add_action( 'plugins_loaded', [ 'ModelContextPolytechnic\\Mcp\\PublicSession', 'init' ] );
add_action( 'plugins_loaded', [ 'ModelContextPolytechnic\\Mcp\\Registry', 'init' ] );
add_action( 'plugins_loaded', [ 'ModelContextPolytechnic\\Mcp\\Learning', 'init' ] );
add_action( 'plugins_loaded', [ 'ModelContextPolytechnic\\Mcp\\BundledCourses', 'init' ] );
add_action( 'plugins_loaded', [ 'ModelContextPolytechnic\\Mcp\\FeedbackCli', 'init' ] );
add_action( 'plugins_loaded', [ 'ModelContextPolytechnic\\Mcp\\Rewrite', 'init' ] );
register_activation_hook(
__FILE__,
static function () {
ModelContextPolytechnic\Mcp\Auth::install_table();
ModelContextPolytechnic\Mcp\PublicSession::install_user();
ModelContextPolytechnic\Mcp\Registry::install_tables();
ModelContextPolytechnic\Mcp\Learning::install_tables();
ModelContextPolytechnic\Mcp\BundledCourses::seed_all();
ModelContextPolytechnic\Mcp\Rewrite::add_rules();
flush_rewrite_rules();
}
);
register_deactivation_hook(
__FILE__,
static function () {
ModelContextPolytechnic\Mcp\Learning::clear_scheduled_cleanup();
flush_rewrite_rules();
}
);