-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionalities.php
More file actions
104 lines (92 loc) · 3.47 KB
/
functionalities.php
File metadata and controls
104 lines (92 loc) · 3.47 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
<?php
/**
* Plugin Name: Dynamic Functionalities
* Plugin URI: https://functionalities.dev
* Description: All-in-one WordPress optimization toolkit. 15+ modules for performance, security, SEO, and content management.
* Version: 1.1.1
* Author: Gaurav Tiwari
* Author URI: https://gauravtiwari.org
* License: GPL-2.0-or-later
* Text Domain: functionalities
* Domain Path: /languages
* Requires at least: 5.8
* Requires PHP: 7.4
*/
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
// Define constants.
if (!defined('FUNCTIONALITIES_VERSION')) {
define('FUNCTIONALITIES_VERSION', '1.1.1');
}
if (!defined('FUNCTIONALITIES_FILE')) {
define('FUNCTIONALITIES_FILE', __FILE__);
}
if (!defined('FUNCTIONALITIES_DIR')) {
define('FUNCTIONALITIES_DIR', plugin_dir_path(__FILE__));
}
if (!defined('FUNCTIONALITIES_URL')) {
define('FUNCTIONALITIES_URL', plugin_dir_url(__FILE__));
}
// Simple autoloader for plugin classes.
spl_autoload_register(function (string $class) {
if (strpos($class, 'Functionalities\\') !== 0) {
return;
}
$parts = explode('\\', $class);
array_shift($parts); // Remove Functionalities
$filename = 'class-' . strtolower(str_replace('_', '-', (string) end($parts))) . '.php';
$subpath = '';
if (count($parts) > 1) {
$subpath = strtolower((string) $parts[0]) . '/';
}
$file = FUNCTIONALITIES_DIR . 'includes/' . $subpath . $filename;
if (file_exists($file)) {
require_once $file;
}
});
// Initialize plugin on init hook.
\add_action('init', function () {
\Functionalities\Admin\Admin::init();
\Functionalities\Features\Link_Management::init();
\Functionalities\Features\Block_Cleanup::init();
\Functionalities\Features\Editor_Links::init();
\Functionalities\Features\Misc::init();
\Functionalities\Features\Snippets::init();
\Functionalities\Features\Schema::init();
\Functionalities\Features\Components::init();
\Functionalities\Features\Fonts::init();
\Functionalities\Features\Meta::init();
\Functionalities\Features\Content_Regression::init();
\Functionalities\Features\Assumption_Detection::init();
\Functionalities\Features\Task_Manager::init();
\Functionalities\Features\Redirect_Manager::init();
\Functionalities\Features\Login_Security::init();
\Functionalities\Features\SVG_Icons::init();
\Functionalities\Features\PWA::init();
}, 10);
// Activation hook.
\register_activation_hook(__FILE__, function () {
if (function_exists('flush_rewrite_rules')) {
\flush_rewrite_rules();
}
});
// Quick Settings link on the Plugins screen.
\add_filter('plugin_action_links_' . \plugin_basename(__FILE__), function (array $links): array {
$url = \admin_url('admin.php?page=functionalities');
$links[] = '<a href="' . \esc_url($url) . '">' . \esc_html__('Settings', 'functionalities') . '</a>';
return $links;
});
// Add meta links on the Plugins screen (row meta).
\add_filter('plugin_row_meta', function (array $links, string $file): array {
if (\plugin_basename(__FILE__) === $file) {
$links[] = '<a href="https://wordpress.org/support/plugin/functionalities/" target="_blank" rel="noopener">' . \esc_html__('Support', 'functionalities') . '</a>';
$links[] = '<a href="https://github.com/wpgaurav/functionalities/issues" target="_blank" rel="noopener">' . \esc_html__('Report Issues', 'functionalities') . '</a>';
}
return $links;
}, 10, 2);
\register_deactivation_hook(__FILE__, function () {
if (function_exists('flush_rewrite_rules')) {
\flush_rewrite_rules();
}
});