PluginProbe
Module Control for Jetpack / 1.7.1
Module Control for Jetpack v1.7.1
1.7.4 1.7.3 trunk 0.4 1.0 1.2 1.3 1.4 1.4.1 1.4.2 1.5 1.6 1.7 1.7.1 1.7.2
jetpack-module-control / jetpack-module-control.php

jetpack-module-control.php in Module Control for Jetpack 1.7.1, at jetpack-module-control.php

85 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Module Control for Jetpack
4 * Plugin URI: https://status301.net/wordpress-plugins/jetpack-module-control/
5 * 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.
6 * Author: RavanH
7 * Author URI: https://status301.net/
8 * Requires Plugins: jetpack
9 * Network: true
10 * Text Domain: jetpack-module-control
11 * License: GPL2+
12 * Version: 1.7.1
13 *
14 * @package Module Control for Jetpack
15 */
16
17 /*
18 * ROADMAP
19 *
20 * version 2.0
21 * Replace "Prevent the Jetpack plugin from auto-activating (new) modules" with
22 * finer grained "Select which modules to auto-activate"
23 * see http://jeremy.hu/customize-the-list-of-modules-available-in-jetpack/
24 * function jeherve_auto_activate_stats() {
25 return array( 'stats' );
26 }
27 add_filter( 'jetpack_get_default_modules', 'jeherve_auto_activate_stats' );
28 *
29 * TO CONSIDER
30 *
31 * Make blacklist or whitelist optional
32 *
33 * Option to disable JUMPSTART with "Jetpack_Options::update_option( 'jumpstart', 'jumpstart_dismissed' );" ??
34 * or do we need to go through apply_filters( 'jetpack_module_feature' ...
35 * If we want to be able to select which modules should appear in Jumpstart later!
36 *
37 * Can we disable Debug link in the footer menu?
38 *
39 * Option to "force_deactivate" (same as blacklist?) as described on https://github.com/Automattic/jetpack/issues/1452
40 *
41 */
42
43 defined( 'WPINC' ) || die( 'No direct access allowed.' );
44
45 define( 'JMC_BASENAME', plugin_basename( __FILE__ ) );
46
47 add_filter( 'jetpack_get_default_modules', array( '\JMC\Plugin', 'manual_control' ), 99 );
48 add_filter( 'jetpack_offline_mode', array( '\JMC\Plugin', 'development_mode' ) );
49 add_filter( 'jetpack_get_available_modules', array( '\JMC\Plugin', 'blacklist' ) );
50
51 add_action( 'admin_init', array( '\JMC\Admin', 'init' ), 11 );
52
53 register_activation_hook( __FILE__, array( '\JMC\Admin', 'activate' ) );
54 register_deactivation_hook( __FILE__, array( '\JMC\Admin', 'deactivate' ) );
55
56 /**
57 * Register JMC autoloader
58 * http://justintadlock.com/archives/2018/12/14/php-namespaces-for-wordpress-developers
59 *
60 * @since 1.7
61 *
62 * @param string $class_name Namespaced class name.
63 */
64 spl_autoload_register(
65 function ( $class_name ) {
66 // Bail if the class is not in our namespace.
67 if ( 0 !== strpos( $class_name, 'JMC\\' ) ) {
68 return;
69 }
70
71 // Build the filename and path.
72 $class_name = str_replace( 'JMC', 'inc', $class_name );
73 $class_name = strtolower( $class_name );
74 $path_array = explode( '\\', $class_name );
75 $class_name = array_pop( $path_array );
76 $class_name = str_replace( '_', '-', $class_name );
77 $file = realpath( __DIR__ ) . DIRECTORY_SEPARATOR . \implode( DIRECTORY_SEPARATOR, $path_array ) . DIRECTORY_SEPARATOR . 'class-' . $class_name . '.php';
78
79 // If the file exists for the class name, load it.
80 if ( file_exists( $file ) ) {
81 include_once $file;
82 }
83 }
84 );
85