Repository navigation
Expand file tree
/
Copy pathfunctionalities.php
More file actions
135 lines (121 loc) · 4.6 KB
/
Copy pathfunctionalities.php
File metadata and controls
135 lines (121 loc) · 4.6 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
/**
* Plugin Name: Dynamic Functionalities
* Plugin URI: https://functionalities.dev
* Description: All-in-one WordPress optimization toolkit. 19 modules for performance, security, SEO, and content management.
* Version: 1.7.0
* Author: Gaurav Tiwari
* Author URI: https://gauravtiwari.org
* License: GPL-2.0-or-later
* Text Domain: functionalities
* Domain Path: /languages
* Requires at least: 6.3
* Requires PHP: 7.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// Define constants.
if ( ! defined( 'FUNCTIONALITIES_VERSION' ) ) {
define( 'FUNCTIONALITIES_VERSION', '1.7.0' );
}
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
$subpath = '';
if ( count( $parts ) > 1 ) {
$subpath = strtolower( (string) $parts[0] ) . '/';
}
$basename = strtolower( str_replace( '_', '-', (string) end( $parts ) ) );
// Try class- prefix first, then trait- prefix.
$file = FUNCTIONALITIES_DIR . 'includes/' . $subpath . 'class-' . $basename . '.php';
if ( ! file_exists( $file ) ) {
$file = FUNCTIONALITIES_DIR . 'includes/' . $subpath . 'trait-' . $basename . '.php';
}
if ( file_exists( $file ) ) {
require_once $file;
}
}
);
// Retained activity history remains erasable/exportable even with its module off.
\add_action( 'deleted_user', array( '\\Functionalities\\Features\\Site_Activity', 'anonymize_user' ) );
\add_action( 'wpmu_delete_user', array( '\\Functionalities\\Features\\Site_Activity', 'anonymize_network_user' ) );
\add_filter( 'wp_privacy_personal_data_erasers', array( '\\Functionalities\\Features\\Site_Activity', 'register_eraser' ) );
\add_filter( 'wp_privacy_personal_data_exporters', array( '\\Functionalities\\Features\\Site_Activity', 'register_exporter' ) );
// Initialize admin and only the modules required for this request.
\add_action(
'plugins_loaded',
function () {
\Functionalities\Core\WordPress_7_Integration::init();
if ( \is_admin() ) {
\Functionalities\Core\Upgrader::maybe_upgrade();
\Functionalities\Admin\Admin::init();
}
\Functionalities\Admin\Site_Health_Controller::init();
\add_action( 'init', array( '\Functionalities\Core\Module_Registry', 'boot' ), 5 );
},
10
);
\add_action( 'updated_option', array( '\Functionalities\Core\Module_Registry', 'handle_option_update' ), 10, 3 );
\add_action( 'added_option', array( '\Functionalities\Core\Module_Registry', 'handle_option_add' ), 10, 2 );
// Activation hook.
\register_activation_hook(
__FILE__,
function () {
if ( \Functionalities\Core\Module_Registry::is_enabled( 'pwa' ) ) {
\Functionalities\Core\Module_Registry::boot_module( 'pwa' );
}
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 () {
\wp_clear_scheduled_hook( 'functionalities_assumption_background_scan' );
\wp_clear_scheduled_hook( 'functionalities_redirect_flush_buffer' );
\wp_clear_scheduled_hook( 'functionalities_link_health_batch' );
\wp_clear_scheduled_hook( 'functionalities_link_health_weekly' );
\wp_clear_scheduled_hook( 'functionalities_activity_prune' );
if ( function_exists( 'flush_rewrite_rules' ) ) {
\flush_rewrite_rules();
}
}
);