Plugin Directory

Changeset 881818


Ignore:
Timestamp:
03/25/2014 04:15:49 PM (12 years ago)
Author:
samface
Message:

checking in release candidate for version 0.4

Location:
angry-creative-logger/trunk
Files:
16 added
5 edited

Legend:

Unmodified
Added
Removed
  • angry-creative-logger/trunk/classes/inspector.php

    r839003 r881818  
    22/*
    33Class name: AC Inspector
    4 Version: 0.3
     4Version: 0.4
    55Author: Sammy Nordström, Angry Creative AB
    66*/
     
    3434            );
    3535
     36            $this->_on_update();
     37
     38            add_action( 'ac_inspection', function() {
     39                AC_Inspector::log("Inspection completed with " . AC_Inspector::$_log_count . " remarks.");
     40            }, 999, 0 );
     41
    3642        }
    3743
     
    5056        }
    5157
     58        /* Plugin update actions */
     59        private function _on_update() {
     60
     61            if ( version_compare(get_option(__CLASS__.'_Version', true), ACI_PLUGIN_VERSION, '<') ) {
     62
     63                $this->deactivate();
     64                $this->activate();
     65
     66                set_option(__CLASS__.'_Version', ACI_PLUGIN_VERSION);
     67
     68            }
     69
     70        }
     71
    5272        public static function get_log_levels() {
    5373
     
    188208
    189209            do_action( 'ac_inspection' );
    190 
    191             self::log("Inspection completed with " . self::$_log_count . " remarks.");
    192210
    193211        }
  • angry-creative-logger/trunk/classes/routine_handler.php

    r839072 r881818  
    22/*
    33Class name: ACI Routine Handler
    4 Version: 0.1.1
    5 Depends: AC Inspector 0.3.x
     4Version: 0.2
     5Depends: AC Inspector 0.4.x
    66Author: Sammy Nordström, Angry Creative AB
    77*/
     
    3131        }
    3232
     33        public static function get_inspection_method($routine, $options = array()) {
     34
     35            if (empty($routine)) {
     36                return false;
     37            }
     38
     39            if (!is_array($options) || empty($options)) {
     40
     41                $options = self::get_options($routine);
     42
     43                if (!is_array($options)) {
     44                    $options = array();
     45                }
     46
     47            }
     48
     49            if (class_exists($routine)) {
     50
     51                if ($options['inspection_method'] && method_exists($routine, $options['inspection_method'])) {
     52
     53                    return array($routine, $options['inspection_method']);
     54
     55                } else if (method_exists($routine, 'inspect')) {
     56
     57                    return array($routine, 'inspect');
     58
     59                }
     60
     61            }
     62
     63            if (!empty($options['inspection_method']) && function_exists($options['inspection_method'])) {
     64
     65                return $options['inspection_method'];
     66
     67            } else if (function_exists($routine)) {
     68
     69                return $routine;
     70
     71            }
     72
     73            return false;
     74
     75        }
     76
    3377        public static function set_options($routine, $args = array()) {
    3478
     
    67111        public static function add($routine, $options = array(), $action = "ac_inspection", $priority = 10, $accepted_args = 1) {
    68112
    69             if ( empty($routine) ) {
     113            $inspection_method = self::get_inspection_method($routine);
     114
     115            if ( !$inspection_method ) {
    70116                return false;
    71117            }
     
    95141            }
    96142
    97             add_action( $action, $routine, $priority, $accepted_args );
     143            add_action( $action, $inspection_method, $priority, $accepted_args );
    98144
    99145            return true;
  • angry-creative-logger/trunk/classes/settings.php

    r860106 r881818  
    22/*
    33Class name: ACI Settings
    4 Version: 0.1.1
    5 Depends: AC Inspector 0.3.x
     4Version: 0.2
     5Depends: AC Inspector 0.4.x
    66Author: Sammy Nordström, Angry Creative AB
    77*/
     
    215215                'aci_general_options',
    216216                'General',
    217                 array( $this, 'print_log_path_info' ),
     217                array( $this, 'print_general_settings_info' ),
    218218                'ac-inspector'
    219219            ); 
     
    232232               
    233233                add_settings_section(
    234                     'aci_inspection_routine_options',
     234                    'aci_inspection_routine_settings',
    235235                    'Routines on General Inspection',
    236                     array( $this, 'print_inspection_routine_options_info' ),
     236                    array( $this, 'print_inspection_routine_settings_info' ),
    237237                    'ac-inspector'
    238                 ); 
     238                );
     239
     240                $routine_fields = array(); 
    239241
    240242                foreach( $inspection_routines as $routine ) {
    241243
    242                     $routine_label = ucwords(str_replace("_", " ", str_replace("wp_", "", str_replace("aci_", "", $routine))));
    243                     $routine_options_key = ACI_Routine_Handler::routine_options_key($routine);
     244                    $routine_settings_fields[$routine] = array();
     245
     246                    $routine_settings_fields[$routine]['id'] = $routine.'_settings_field';
     247                    $routine_settings_fields[$routine]['title'] = ucwords(str_replace("_", " ", str_replace("wp_", "", str_replace("aci_", "", str_replace("routine_", "", strtolower($routine))))));
     248                    $routine_settings_fields[$routine]['callback'] = array( &$this, 'routine_settings_field' );
     249                    $routine_settings_fields[$routine]['page'] = 'ac-inspector';
     250                    $routine_settings_fields[$routine]['section'] = 'aci_inspection_routine_settings';
     251                    $routine_settings_fields[$routine]['args'] = array('routine' => $routine);
     252
     253                    $routine_settings_fields[$routine] = apply_filters( $routine.'_settings_field_args', $routine_settings_fields[$routine] );
     254                           
     255                }
     256
     257                foreach( $routine_settings_fields as $routine_field ) {
    244258
    245259                    add_settings_field(
    246                         $routine.'_log_level',
    247                         $routine_label,
    248                         array( $this, 'log_level_field' ),
    249                         'ac-inspector',
    250                         'aci_inspection_routine_options',
    251                         array('routine' => $routine)       
     260                        $routine_field['id'],
     261                        $routine_field['title'],
     262                        $routine_field['callback'],
     263                        $routine_field['page'],
     264                        $routine_field['section'],
     265                        $routine_field['args']     
    252266                    );
    253                            
     267
    254268                }
    255269
     
    261275               
    262276                add_settings_section(
    263                     'aci_wp_hook_routine_options',
     277                    'aci_wp_hook_routine_settings',
    264278                    'Routines on WP Hooks',
    265                     array( $this, 'print_wp_hook_routine_options_info' ),
     279                    array( $this, 'print_wp_hook_routine_settings_info' ),
    266280                    'ac-inspector'
    267281                ); 
     
    269283                foreach( $wp_hook_routines as $routine ) {
    270284
    271                     $routine_label = ucwords(str_replace("_", " ", str_replace("wp_", "", str_replace("aci_", "", $routine))));
    272                     $routine_options_key = ACI_Routine_Handler::routine_options_key($routine);
     285                    $routine_settings_fields[$routine] = array();
     286
     287                    $routine_settings_fields[$routine]['id'] = $routine.'_settings_field';
     288                    $routine_settings_fields[$routine]['title'] = ucwords(str_replace("_", " ", str_replace("wp_", "", str_replace("aci_", "", str_replace("routine_", "", strtolower($routine))))));
     289                    $routine_settings_fields[$routine]['callback'] = array( &$this, 'routine_settings_field' );
     290                    $routine_settings_fields[$routine]['page'] = 'ac-inspector';
     291                    $routine_settings_fields[$routine]['section'] = 'aci_wp_hook_routine_settings';
     292                    $routine_settings_fields[$routine]['args'] = array('routine' => $routine);
     293
     294                    $routine_settings_fields[$routine] = apply_filters( $routine.'_settings_field_args', $routine_settings_fields[$routine] );
     295                           
     296                }
     297
     298                foreach( $routine_settings_fields as $routine_field ) {
    273299
    274300                    add_settings_field(
    275                         $routine.'_log_level',
    276                         $routine_label,
    277                         array( $this, 'log_level_field' ),
    278                         'ac-inspector',
    279                         'aci_wp_hook_routine_options',
    280                         array('routine' => $routine)       
     301                        $routine_field['id'],
     302                        $routine_field['title'],
     303                        $routine_field['callback'],
     304                        $routine_field['page'],
     305                        $routine_field['section'],
     306                        $routine_field['args']     
    281307                    );
    282                            
     308
    283309                }
    284310
     
    311337            foreach( array_keys($routines) as $routine ) {
    312338
    313                 $routine_options = ACI_Routine_Handler::get_options($routine);
    314                 $new_routine_options = $input[$routine];
    315 
    316                 foreach($routine_options as $opt => $val) {
    317 
    318                     if (isset($new_routine_options[$opt])) {
    319                         $routine_options[$opt] = $new_routine_options[$opt];
     339                $routine_settings = ACI_Routine_Handler::get_options($routine);
     340                $new_routine_settings = $input[$routine];
     341
     342                foreach($routine_settings as $opt => $val) {
     343
     344                    if (isset($new_routine_settings[$opt])) {
     345                        $routine_settings[$opt] = $new_routine_settings[$opt];
    320346                    }
    321347
    322348                }
    323349
    324                 ACI_Routine_Handler::set_options( $routine, $routine_options );
     350                $routine_settings = apply_filters( $routine.'_settings', $routine_settings );
     351
     352                echo $routine . "<br />";
     353
     354                var_dump($routine_settings);
     355
     356                ACI_Routine_Handler::set_options( $routine, $routine_settings );
    325357
    326358            }
     
    344376        }
    345377       
    346         public function print_log_path_info() {
     378        public function print_general_settings_info() {
    347379
    348380            print 'These are your general settings:';
     
    350382        }
    351383
    352         public function print_inspection_routine_options_info() {
     384        public function print_inspection_routine_settings_info() {
    353385
    354386            print 'Below you can set options for your inspection routines on scheduled and user activated inspections:';
     
    356388        }
    357389
    358         public function print_wp_hook_routine_options_info() {
     390        public function print_wp_hook_routine_settings_info() {
    359391
    360392            print 'Below you can set options for your inspection routines triggered by Wordpress hooks:';
     
    370402        }
    371403
    372         public function log_level_field($args) {
     404        public function routine_settings_field($args) {
    373405
    374406            $routine = $args['routine'];
    375407            $log_levels = AC_Inspector::get_log_levels();
    376             $routine_options = ACI_Routine_Handler::get_options($routine);
     408            $routine_settings = ACI_Routine_Handler::get_options($routine);
    377409
    378410            ?>
     
    384416                        <?php foreach( $log_levels as $level ) { ?>
    385417
    386                             <option value="<?php echo $level; ?>"<?php echo ($level == $routine_options['log_level']) ? " selected" : ""; ?>><?php echo ucfirst($level); ?></option>
     418                            <option value="<?php echo $level; ?>"<?php echo ($level == $routine_settings['log_level']) ? " selected" : ""; ?>><?php echo ucfirst($level); ?></option>
    387419
    388420                        <?php } ?>
     
    393425            <?php
    394426
     427            do_action($routine.'_settings_field', $routine_settings, $args);
     428
    395429        }
    396430
  • angry-creative-logger/trunk/plugin.php

    r860106 r881818  
    44Plugin URI: http://angrycreative.se
    55Description: Inspects and logs possible issues with your Wordpress installation.
    6 Version: 0.3.3
     6Version: 0.4
    77Author: Robin Björklund, Sammy Nordström, Angry Creative AB
    88*/
    99
    10 define('ACI_PLUGIN_DIR', dirname( __FILE__ ) );
    11 define('ACI_PLUGIN_FILE',  __FILE__ );
    12 define('ACI_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
     10define( 'ACI_PLUGIN_VERSION', '0.4' );
     11
     12define( 'ACI_PLUGIN_DIR', dirname( __FILE__ ) );
     13define( 'ACI_PLUGIN_FILE',  __FILE__ );
     14define( 'ACI_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
    1315
    1416// Needed for multisite support
     
    2527
    2628// Load inspection routines
    27 require( ACI_PLUGIN_DIR . "/routines.php" );
     29foreach ( glob( ACI_PLUGIN_DIR."/routines/*.php" ) as $routine_file ) {
     30    include $routine_file;
     31}
    2832
    2933// If in admin, also load settings class
  • angry-creative-logger/trunk/readme.txt

    r860106 r881818  
    33Tags: inspect, inspection, monitor, monitoring, log, logging, check, checking, validate, validation, permissions, install, installation
    44Requires at least: 3.0.1
    5 Tested up to: 3.8
    6 Stable tag: 0.3.3
     5Tested up to: 3.8.1
     6Stable tag: 0.4
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2222== Changelog ==
    2323
     24= 0.4.x =
     25* New routine with git support for checking file system changes
     26* Improved pluggability and custom routines support
     27* Added version-awareness and re-activation on update
     28
    2429= 0.3.x =
    2530* Completely rewritten sources abstracting settings and inspection routines
Note: See TracChangeset for help on using the changeset viewer.