-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclassact.php
72 lines (63 loc) · 1.96 KB
/
classact.php
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
<?php
/**
* Plugin Name: ClassAct
* Plugin URI: https://daveryan.co
* Description: A miniplugin for acting on Additional CSS classes per-block in the WordPress Editor.
* Version: 2.0.0
* Author: Dave Ryan
* Author URI: https://daveryan.co
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: classact
* Domain Path: /languages
*
* @package ClassAct
* @version 2.0.0
*/
defined( 'ABSPATH' ) || exit;
// Define plugin constants
if ( ! defined( 'CLASSACT_VERSION' ) ) {
define( 'CLASSACT_VERSION', '2.0.0' );
}
if ( ! defined( 'CLASSACT_FILE' ) ) {
define( 'CLASSACT_FILE', __FILE__ );
}
if ( ! defined( 'CLASSACT_PATH' ) ) {
define( 'CLASSACT_PATH', plugin_dir_path( CLASSACT_FILE ) );
}
if ( ! defined( 'CLASSACT_URL' ) ) {
define( 'CLASSACT_URL', plugin_dir_url( CLASSACT_FILE ) );
}
if ( ! defined( 'CLASSACT_BUILD_DIR' ) ) {
define( 'CLASSACT_BUILD_DIR', CLASSACT_PATH . 'build/' . CLASSACT_VERSION );
}
if ( ! defined( 'CLASSACT_BUILD_URL' ) ) {
define( 'CLASSACT_BUILD_URL', CLASSACT_URL . 'build/' . CLASSACT_VERSION );
}
if( ! defined( 'CLASSACT_DISABLE_AUTOUPDATE' ) ) {
define( 'CLASSACT_DISABLE_AUTOUPDATE', 'false' );
}
// Autoloader for plugin classes
spl_autoload_register( function( $class ) {
// Project-specific namespace prefix
$prefix = 'ClassAct\\';
// Check if the class uses the namespace prefix
$len = strlen( $prefix );
if ( strncmp( $prefix, $class, $len ) !== 0 ) {
return;
}
// Get the relative class name
$relative_class = substr( $class, $len );
// Replace namespace separators with directory separators
$file = CLASSACT_PATH . 'includes/' . str_replace( '\\', '/', $relative_class ) . '.php';
// If the file exists, require it
if ( file_exists( $file ) ) {
require $file;
}
} );
// Initialize the plugin
function classact_init() {
return ClassAct\Plugin::instance();
}
// Start the plugin
classact_init();