-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjetpack-module-control.php
More file actions
86 lines (77 loc) · 3.07 KB
/
jetpack-module-control.php
File metadata and controls
86 lines (77 loc) · 3.07 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
<?php
/**
* Plugin Name: Module Control for Jetpack
* Plugin URI: https://status301.net/wordpress-plugins/jetpack-module-control/
* Description: This plugin brings additional control over Jetpack modules. You can blacklist / remove individual modules, prevent auto-activation or allow activation without a WordPress.com account.
* Author: RavanH
* Author URI: https://status301.net/
* Requires Plugins: jetpack
* Network: true
* Text Domain: jetpack-module-control
* License: GPL2+
* Version: 1.7.2
*
* @package Module Control for Jetpack
*/
/*
* ROADMAP
*
* version 2.0
* Replace "Prevent the Jetpack plugin from auto-activating (new) modules" with
* finer grained "Select which modules to auto-activate"
* see http://jeremy.hu/customize-the-list-of-modules-available-in-jetpack/
* function jeherve_auto_activate_stats() {
return array( 'stats' );
}
add_filter( 'jetpack_get_default_modules', 'jeherve_auto_activate_stats' );
*
* TO CONSIDER
*
* Make blacklist or whitelist optional
*
* Option to disable JUMPSTART with "Jetpack_Options::update_option( 'jumpstart', 'jumpstart_dismissed' );" ??
* or do we need to go through apply_filters( 'jetpack_module_feature' ...
* If we want to be able to select which modules should appear in Jumpstart later!
*
* Can we disable Debug link in the footer menu?
*
* Option to "force_deactivate" (same as blacklist?) as described on https://github.com/Automattic/jetpack/issues/1452
*
*/
defined( 'WPINC' ) || die( 'No direct access allowed.' );
define( 'JMC_BASENAME', plugin_basename( __FILE__ ) );
add_filter( 'jetpack_get_default_modules', array( '\JMC\Plugin', 'manual_control' ), 99 );
add_filter( 'jetpack_offline_mode', array( '\JMC\Plugin', 'development_mode' ) );
add_filter( 'jetpack_get_available_modules', array( '\JMC\Plugin', 'blacklist' ) );
add_action( 'admin_init', array( '\JMC\Admin', 'init' ), 11 );
add_action( 'admin_menu', array( '\JMC\Admin', 'control_submenus' ), 1001 );
add_filter( 'wp_default_autoload_value', array( '\JMC\Admin', 'autoload_value' ), 10, 2 );
register_activation_hook( __FILE__, array( '\JMC\Admin', 'activate' ) );
register_deactivation_hook( __FILE__, array( '\JMC\Admin', 'deactivate' ) );
/**
* Register JMC autoloader
* http://justintadlock.com/archives/2018/12/14/php-namespaces-for-wordpress-developers
*
* @since 1.7
*
* @param string $class_name Namespaced class name.
*/
spl_autoload_register(
function ( $class_name ) {
// Bail if the class is not in our namespace.
if ( 0 !== strpos( $class_name, 'JMC\\' ) ) {
return;
}
// Build the filename and path.
$class_name = str_replace( 'JMC', 'inc', $class_name );
$class_name = strtolower( $class_name );
$path_array = explode( '\\', $class_name );
$class_name = array_pop( $path_array );
$class_name = str_replace( '_', '-', $class_name );
$file = realpath( __DIR__ ) . DIRECTORY_SEPARATOR . \implode( DIRECTORY_SEPARATOR, $path_array ) . DIRECTORY_SEPARATOR . 'class-' . $class_name . '.php';
// If the file exists for the class name, load it.
if ( file_exists( $file ) ) {
include_once $file;
}
}
);