WordPress.org

Plugin Directory

Changeset 791595


Ignore:
Timestamp:
10/22/13 04:02:21 (6 months ago)
Author:
markjaquith
Message:

Much simpler way of preventing modules from auto-activating, thanks to georgestephanis.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • manual-control/trunk/manual-control.php

    r488668 r791595  
    33Plugin Name: Manual Control for Jetpack 
    44Description: Prevents the Jetpack plugin from auto-activating its new features. 
    5 Version: 0.1 
     5Version: 0.2 
    66Author: Mark Jaquith 
    77Author URI: http://coveredwebservices.com/ 
     
    1010class CWS_Manual_Control_for_Jetpack_Plugin { 
    1111    static $instance; 
    12     static $jetpack; 
    13     const MESSAGE = 'stop_auto_activating'; 
    1412 
    1513    function __construct() { 
     
    1917 
    2018    function init() { 
    21         if ( class_exists( 'Jetpack' ) ) { 
    22             if ( method_exists( 'Jetpack', 'init' ) ) 
    23                 self::$jetpack = Jetpack::init(); 
    24             add_action( 'load-toplevel_page_jetpack', array( $this, 'before_load' ), 9 ); 
    25         } 
     19        add_filter( 'jetpack_get_default_modules', array( $this, 'empty_array' ), 99 ); 
    2620    } 
    2721 
    28     function before_load() { 
    29         if ( class_exists( 'Jetpack' ) ) { 
    30             Jetpack::state( 'error', self::MESSAGE ); 
    31             add_action( 'jetpack_notices', array( $this, 'kill_notice' ), 0 ); 
    32         } 
     22    function empty_array() { 
     23        return array(); 
    3324    } 
    34  
    35     function kill_notice() { 
    36         if ( Jetpack::state( 'error' ) == self::MESSAGE ) { 
    37             self::$jetpack->error = false; 
    38         } 
    39     } 
    40  
    4125} 
    4226 
Note: See TracChangeset for help on using the changeset viewer.