Plugin Directory

Changeset 958135


Ignore:
Timestamp:
07/31/2014 03:00:15 PM (12 years ago)
Author:
samface
Message:

Fixed problem with saved options for write permissions routine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • angry-creative-logger/trunk/routines/write_permissions.php

    r958063 r958135  
    88    const LOG_LEVEL = 'warning';
    99
     10    const DESCRIPTION = 'Checks wether your web server has the appropriate write permissions.';
     11
    1012    private static $_default_allowed_dirs = array(
    11         'wp-content/uploads/*'
     13        'wp-content/uploads/*',
     14        'wp-content/plugins/*',
     15        'wp-content/themes/*',
     16        'wp-content/languages/*',
    1217    );
    1318
     19    private static $_force_default_allowed_dirs = false;
     20
    1421    private static $_options = array();
    1522
    16     public static function register() {
     23    private static $_instantiated = false;
     24
     25    public static function preload() {
    1726
    1827        if ( defined('DISALLOW_FILE_MODS') && true == DISALLOW_FILE_MODS ) {
    1928            self::$_default_allowed_dirs = array( 'wp-content/uploads/*' );
     29            self::$_force_default_allowed_dirs = true;
    2030        }
    2131
    2232        if ( defined('FS_METHOD') && 'direct' == FS_METHOD ) {
    2333            self::$_default_allowed_dirs = array( '/*' );
    24         }
    25 
    26         $default_options = array( 'log_level' => self::LOG_LEVEL,
    27                                   'allowed_dirs' => self::$_default_allowed_dirs ,
    28                                   'description' => "Checks wether your web server has the appropriate write permissions.");
     34            self::$_force_default_allowed_dirs = true;
     35        }
     36
     37    }
     38
     39    public static function register() {
     40
     41        self::preload();
     42
     43        $reg_options = array( 'log_level' => self::LOG_LEVEL,
     44                              'allowed_dirs' => self::$_default_allowed_dirs,
     45                              'description' => self::DESCRIPTION );
    2946       
    30         aci_register_routine( __CLASS__, $default_options );
     47        aci_register_routine( __CLASS__, $reg_options );
     48
     49        self::setup();
     50
     51        if ( !self::$_force_default_allowed_dirs ) {
     52
     53            add_action( __CLASS__.'_settings_field', array( __CLASS__, 'settings_field' ), 10, 2 );
     54            add_filter( __CLASS__.'_settings',  array( __CLASS__, 'settings' ), 10, 1 );
     55
     56        }
     57
     58    }
     59
     60    public static function setup() {
    3161
    3262        self::$_options = ACI_Routine_Handler::get_options( __CLASS__ );
     
    3666        }
    3767
    38         if ( !is_array( self::$_options['allowed_dirs'] ) ) {
    39             self::$_options['allowed_dirs'] = array();
    40         }
    41 
    42         if ( ( !defined('DISALLOW_FILE_MODS') || false == DISALLOW_FILE_MODS ) && ( !defined('FS_METHOD') || 'direct' != FS_METHOD ) ) {
     68        if ( self::$_force_default_allowed_dirs ) {
     69
    4370            self::$_options['allowed_dirs'] = self::$_default_allowed_dirs;
    44             add_action( __CLASS__.'_settings_field', array( __CLASS__, 'settings_field' ), 10, 2 );
    45             add_filter( __CLASS__.'_settings',  array( __CLASS__, 'settings' ), 10, 1 );
     71
     72        } else {
     73
     74            if ( !is_array( self::$_options['allowed_dirs'] ) || empty( self::$_options['allowed_dirs'] ) ) {
     75                self::$_options['allowed_dirs'] = self::$_default_allowed_dirs;
     76            }
     77
    4678        }
    4779
     
    141173        $routine = $args['routine'];
    142174
     175        if ( empty( $options['allowed_dirs'] ) || self::$_force_default_allowed_dirs ) {
     176            $options['allowed_dirs'] = self::$_default_allowed_dirs;
     177        }
     178
    143179        ?>
    144180
     
    157193    public static function settings( $options ) {
    158194
    159         if ( !empty( $options['allowed_dirs'] ) && false != strpos( $options['allowed_dirs'], "\n" ) ) {
     195        if ( empty( $options['allowed_dirs'] ) || self::$_force_default_allowed_dirs ) {
     196            $options['allowed_dirs'] = self::$_default_allowed_dirs;
     197        }
     198
     199        if ( false != strpos( $options['allowed_dirs'], "\n" ) ) {
    160200            $options['allowed_dirs'] = array_map('trim', explode("\n", $options['allowed_dirs']));
    161201        }
Note: See TracChangeset for help on using the changeset viewer.