-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpp-glossary.php
More file actions
100 lines (88 loc) · 2.64 KB
/
pp-glossary.php
File metadata and controls
100 lines (88 loc) · 2.64 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
<?php
/**
* Plugin Name: Glossary
* Plugin URI: https://progressplanner.com
* Description: A semantic, accessible glossary plugin that automatically links terms to popover definitions.
* Version: 1.3.1
* Author: Team Progress Planner
* Author URI: https://progressplanner.com
* License: GPL v3 or later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* GitHub Plugin URI: https://github.com/progressplanner/pp-glossary
* Primary Branch: main
* Release Asset: true
* Text Domain: pp-glossary
* Plugin ID: did:plc:m5tfrwxd3btacxlstcvop2ib
* Security: security@progressplanner.com
* Requires at least: 6.0
* Requires PHP: 7.4
*
* @package PP_Glossary
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
define( 'PP_GLOSSARY_VERSION', '1.3.1' );
define( 'PP_GLOSSARY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'PP_GLOSSARY_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
require_once PP_GLOSSARY_PLUGIN_DIR . 'includes/functions.php';
/**
* Autoloader for PP_Glossary classes.
*
* @param string $class_name The fully qualified class name to load.
*
* @return void
*/
function pp_glossary_autoloader( string $class_name ): void {
// Only handle PP_Glossary namespace classes.
if ( strpos( $class_name, 'PP_Glossary\\' ) !== 0 ) {
return;
}
// Remove the PP_Glossary\ namespace prefix.
$class_name = substr( $class_name, strlen( 'PP_Glossary\\' ) );
// Convert class name to file name format.
// PP_Glossary\Settings -> class-settings.php -> includes/class-settings.php.
$file_name = 'class-' . str_replace( '_', '-', strtolower( $class_name ) ) . '.php';
$file_path = PP_GLOSSARY_PLUGIN_DIR . 'includes/' . $file_name;
// Load the file if it exists.
if ( file_exists( $file_path ) ) {
require_once $file_path;
}
}
// Register the autoloader.
spl_autoload_register( 'pp_glossary_autoloader' );
/**
* Initialize the plugin.
*/
function pp_glossary_init(): void {
// Initialize components.
\PP_Glossary\Settings::init();
\PP_Glossary\Post_Type::init();
\PP_Glossary\Blocks::init();
\PP_Glossary\Schema::init();
if ( is_admin() ) {
\PP_Glossary\Meta_Boxes::init();
\PP_Glossary\Migrations::init();
} else {
\PP_Glossary\Content_Filter::init();
\PP_Glossary\Assets::init();
}
}
add_action( 'plugins_loaded', 'pp_glossary_init' );
/**
* Activation hook
*/
function pp_glossary_activate(): void {
// Flush rewrite rules.
pp_glossary_init();
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'pp_glossary_activate' );
/**
* Deactivation hook
*/
function pp_glossary_deactivate(): void {
flush_rewrite_rules();
}
register_deactivation_hook( __FILE__, 'pp_glossary_deactivate' );