PluginProbe
Module Control for Jetpack / 1.7.4
Module Control for Jetpack v1.7.4
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.4, at jetpack-module-control.php

86 lines 3.1 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.4
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 * Option to "force_deactivate" (same as blacklist?) as described on https://github.com/Automattic/jetpack/issues/1452
38 *
39 */
40
41 defined( 'WPINC' ) || die( 'No direct access allowed.' );
42
43 define( 'JMC_BASENAME', plugin_basename( __FILE__ ) );
44
45 add_filter( 'jetpack_get_default_modules', array( '\JMC\Plugin', 'manual_control' ), 99 );
46 add_filter( 'jetpack_offline_mode', array( '\JMC\Plugin', 'development_mode' ) );
47 add_filter( 'jetpack_get_available_modules', array( '\JMC\Plugin', 'blacklist' ) );
48 add_filter( 'jetpack_ai_enabled', array( '\JMC\Plugin', 'ai_enabled' ) );
49
50 add_action( 'admin_init', array( '\JMC\Admin', 'init' ), 11 );
51 add_action( 'admin_menu', array( '\JMC\Admin', 'control_submenus' ), 1001 );
52 add_filter( 'wp_default_autoload_value', array( '\JMC\Admin', 'autoload_value' ), 10, 2 );
53
54 register_activation_hook( __FILE__, array( '\JMC\Admin', 'activate' ) );
55 register_deactivation_hook( __FILE__, array( '\JMC\Admin', 'deactivate' ) );
56
57 /**
58 * Register JMC autoloader
59 * http://justintadlock.com/archives/2018/12/14/php-namespaces-for-wordpress-developers
60 *
61 * @since 1.7
62 *
63 * @param string $class_name Namespaced class name.
64 */
65 spl_autoload_register(
66 function ( $class_name ) {
67 // Bail if the class is not in our namespace.
68 if ( 0 !== strpos( $class_name, 'JMC\\' ) ) {
69 return;
70 }
71
72 // Build the filename and path.
73 $class_name = str_replace( 'JMC', 'inc', $class_name );
74 $class_name = strtolower( $class_name );
75 $path_array = explode( '\\', $class_name );
76 $class_name = array_pop( $path_array );
77 $class_name = str_replace( '_', '-', $class_name );
78 $file = realpath( __DIR__ ) . DIRECTORY_SEPARATOR . \implode( DIRECTORY_SEPARATOR, $path_array ) . DIRECTORY_SEPARATOR . 'class-' . $class_name . '.php';
79
80 // If the file exists for the class name, load it.
81 if ( file_exists( $file ) ) {
82 include_once $file;
83 }
84 }
85 );
86