Changeset 958566
- Timestamp:
- 08/01/2014 09:21:56 AM (12 years ago)
- Location:
- angry-creative-logger/trunk
- Files:
-
- 4 edited
-
classes/routine_handler.php (modified) (11 diffs)
-
classes/settings.php (modified) (8 diffs)
-
plugin.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
angry-creative-logger/trunk/classes/routine_handler.php
r943414 r958566 2 2 /* 3 3 Class name: ACI Routine Handler 4 Version: 0.3. 04 Version: 0.3.1 5 5 Depends: AC Inspector 0.5.x 6 6 Author: Sammy Nordström, Angry Creative AB … … 30 30 } 31 31 32 public static function get_inspection_method( $routine, $options = array()) {33 34 if ( empty($routine)) {35 return false; 36 } 37 38 if ( !is_array($options) || empty($options)) {39 40 $options = self::get_options( $routine);41 42 if ( !is_array($options)) {32 public static function get_inspection_method( $routine, $options = array() ) { 33 34 if ( empty( $routine ) ) { 35 return false; 36 } 37 38 if ( !is_array( $options ) || empty( $options ) ) { 39 40 $options = self::get_options( $routine ); 41 42 if ( !is_array( $options ) ) { 43 43 $options = array(); 44 44 } … … 46 46 } 47 47 48 if ( class_exists($routine)) {49 50 if ( $options['inspection_method'] && method_exists($routine, $options['inspection_method'])) {51 52 return array( $routine, $options['inspection_method']);53 54 } else if ( method_exists($routine, 'inspect')) {55 56 return array( $routine, 'inspect');48 if ( class_exists( $routine ) ) { 49 50 if ( !empty( $options['inspection_method'] ) && method_exists( $routine, $options['inspection_method'] ) ) { 51 52 return array( $routine, $options['inspection_method'] ); 53 54 } else if ( method_exists( $routine, 'inspect' ) ) { 55 56 return array( $routine, 'inspect' ); 57 57 58 58 } … … 60 60 } 61 61 62 if ( !empty($options['inspection_method']) && function_exists($options['inspection_method'])) {62 if ( !empty( $options['inspection_method'] ) && function_exists( $options['inspection_method'] ) ) { 63 63 64 64 return $options['inspection_method']; 65 65 66 } else if ( function_exists($routine)) {66 } else if ( function_exists( $routine ) ) { 67 67 68 68 return $routine; … … 86 86 } 87 87 88 public static function get_options( $routine) {89 90 if ( empty($routine)) {91 return false; 92 } 93 94 $options_key = self::routine_options_key( $routine);95 96 $options = AC_Inspector::get_option( $options_key);97 98 if ( $options['site_specific_settings']&& is_multisite() && is_plugin_active_for_network( ACI_PLUGIN_BASENAME ) ) {88 public static function get_options( $routine ) { 89 90 if ( empty( $routine ) ) { 91 return false; 92 } 93 94 $options_key = self::routine_options_key( $routine ); 95 96 $options = AC_Inspector::get_option( $options_key ); 97 98 if ( !empty( $options['site_specific_settings'] ) && is_multisite() && is_plugin_active_for_network( ACI_PLUGIN_BASENAME ) ) { 99 99 100 100 global $wpdb; 101 $site_blog_ids = $wpdb->get_col( "SELECT blog_id FROM ".$wpdb->prefix."blogs");102 103 if ( is_array($site_blog_ids)) {104 105 $global_opt_keys = array_keys( $options);101 $site_blog_ids = $wpdb->get_col( "SELECT blog_id FROM ".$wpdb->prefix."blogs" ); 102 103 if ( is_array( $site_blog_ids ) ) { 104 105 $global_opt_keys = array_keys( $options ); 106 106 107 107 foreach( $site_blog_ids AS $site_blog_id ) { 108 108 109 if ( !is_array( $options[$site_blog_id]) ) {109 if ( !is_array( $options[$site_blog_id] ) ) { 110 110 $options[$site_blog_id] = array(); 111 111 } 112 112 113 foreach( $global_opt_keys as $global_opt_key ) {114 115 if ( !is_numeric( $global_opt_key) && $global_opt_key != 'site_specific_settings' && !isset($options[$site_blog_id][$global_opt_key]) ) {113 foreach( $global_opt_keys as $global_opt_key ) { 114 115 if ( !is_numeric( $global_opt_key ) && $global_opt_key != 'site_specific_settings' && !isset( $options[$site_blog_id][$global_opt_key] ) ) { 116 116 $options[$site_blog_id][$global_opt_key] = $options[$global_opt_key]; 117 117 } … … 138 138 } 139 139 140 public static function add( $routine, $options = array(), $action = "ac_inspection", $priority = 10, $accepted_args = 1) {141 142 $inspection_method = self::get_inspection_method( $routine, $options);143 144 if ( !$inspection_method) {145 return false; 146 } 147 148 if ( empty( $action) ) {140 public static function add( $routine, $options = array(), $action = "ac_inspection", $priority = 10, $accepted_args = 1 ) { 141 142 $inspection_method = self::get_inspection_method( $routine, $options ); 143 144 if ( empty( $inspection_method ) ) { 145 return false; 146 } 147 148 if ( empty( $action ) ) { 149 149 $action = "ac_inspection"; 150 150 } 151 151 152 if ( ! is_array( self::$routine_events[$routine] ) ) {152 if ( !array_key_exists( $routine, self::$routine_events ) || !is_array( self::$routine_events[$routine] ) ) { 153 153 self::$routine_events[$routine] = array(); 154 154 } 155 155 156 if ( in_array( $action, self::$routine_events[$routine]) ) {156 if ( in_array( $action, self::$routine_events[$routine] ) ) { 157 157 return false; 158 158 } … … 170 170 } 171 171 172 if ( is_array($options) && !empty( $options ) ) {173 if ( is_array( $saved_options) ) {172 if ( !empty( $options ) && is_array( $options ) ) { 173 if ( is_array( $saved_options ) ) { 174 174 foreach( $saved_options as $opt_key => $saved_val ) { 175 if ( !isset( $options[$opt_key]) || $options[$opt_key] != $saved_val ) {175 if ( !isset( $options[$opt_key] ) || $options[$opt_key] != $saved_val ) { 176 176 $options[$opt_key] = $saved_val; 177 177 } 178 178 } 179 179 } 180 if ( !is_array( $saved_options) || ( count($options) != count($saved_options) ) ) {180 if ( !is_array( $saved_options ) || ( count( $options ) != count( $saved_options ) ) ) { 181 181 self::set_options( $routine, $options ); 182 182 } 183 183 } 184 184 185 if ( $options['site_specific_settings']&& is_multisite() && is_plugin_active_for_network( ACI_PLUGIN_BASENAME ) ) {185 if ( !empty( $options['site_specific_settings'] ) && is_multisite() && is_plugin_active_for_network( ACI_PLUGIN_BASENAME ) ) { 186 186 $current_site_id = get_current_blog_id(); 187 if ( $options[$current_site_id]['log_level'] == 'ignore') {187 if ( $options[$current_site_id]['log_level'] == 'ignore' ) { 188 188 return true; 189 189 } … … 200 200 public static function remove($routine, $action = "", $priority = 10) { 201 201 202 if ( empty($routine)) {202 if ( empty( $routine ) ) { 203 203 return false; 204 204 } … … 214 214 } 215 215 216 unset( self::$routine_events[$routine]);216 unset( self::$routine_events[$routine] ); 217 217 218 218 return true; … … 222 222 public static function get_event_routines($event) { 223 223 224 if ( empty($event)) {224 if ( empty( $event) ) { 225 225 return false; 226 226 } … … 228 228 $event_routines = array(); 229 229 230 foreach( array_keys(self::$routine_events) as $routine) {230 foreach( array_keys( self::$routine_events ) as $routine ) { 231 231 if ( in_array( $event, self::$routine_events[$routine] ) ) { 232 232 $event_routines[] = $routine; -
angry-creative-logger/trunk/classes/settings.php
r943414 r958566 2 2 /* 3 3 Class name: ACI Settings 4 Version: 0.3. 04 Version: 0.3.1 5 5 Depends: AC Inspector 0.5.x 6 6 Author: Sammy Nordström, Angry Creative AB … … 49 49 public function admin_notices() { 50 50 51 if ( 'ac-inspector' == $_GET['page'] && isset( $_GET['updated'] )) {51 if ( isset( $_GET['updated'] ) && isset( $_GET['page'] ) && 'ac-inspector' == $_GET['page'] ) { 52 52 53 53 echo '<div class="updated"><p>'; … … 364 364 public function validate_options( $input = array() ) { 365 365 366 if ( empty($input) && $_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['aci_options'])) {366 if ( empty( $input ) && $_SERVER['REQUEST_METHOD'] == "POST" && isset( $_POST['aci_options'] ) ) { 367 367 $input = $_POST['aci_options']; 368 368 } … … 370 370 $saved_option = parent::get_option( 'ac_inspector_log_path' ); 371 371 372 if ( $saved_option === FALSE ) { 373 374 parent::add_option( 'ac_inspector_log_path', $input['log_path'] ); 375 376 } else { 377 378 parent::update_option( 'ac_inspector_log_path', $input['log_path'] ); 379 380 } 381 382 parent::$log_path = $input['log_path']; 383 384 $routines = ACI_Routine_Handler::get_all(); 372 if ( !empty( $input['log_path'] ) ) { 373 374 if ( $saved_option === FALSE ) { 375 376 parent::add_option( 'ac_inspector_log_path', $input['log_path'] ); 377 378 } else { 379 380 parent::update_option( 'ac_inspector_log_path', $input['log_path'] ); 381 382 } 383 384 parent::$log_path = $input['log_path']; 385 386 } 387 388 $routines = (array) ACI_Routine_Handler::get_all(); 385 389 386 390 foreach( array_keys($routines) as $routine ) { … … 388 392 $routine_settings = ACI_Routine_Handler::get_options($routine); 389 393 390 $new_routine_settings = $input[$routine]; 394 if ( !empty( $input[$routine] ) && is_array( $input[$routine] ) ) { 395 $new_routine_settings = $input[$routine]; 396 } else { 397 $new_routine_settings = array(); 398 } 391 399 392 400 foreach($routine_settings as $opt => $val) { 393 401 394 if ( isset($new_routine_settings[$opt])) {402 if ( isset( $new_routine_settings[$opt] ) ) { 395 403 $routine_settings[$opt] = $new_routine_settings[$opt]; 396 404 } … … 454 462 $routine_settings = ACI_Routine_Handler::get_options($routine); 455 463 456 if ( !empty( $routine_settings['description']) ) { ?>464 if ( !empty( $routine_settings['description'] ) ) { ?> 457 465 458 466 <tr valign="top"> … … 462 470 <?php } 463 471 464 if ( isset( $routine_settings['site_specific_settings']) && is_multisite() && is_plugin_active_for_network( ACI_PLUGIN_BASENAME ) ) { ?>472 if ( isset( $routine_settings['site_specific_settings'] ) && is_multisite() && is_plugin_active_for_network( ACI_PLUGIN_BASENAME ) ) { ?> 465 473 466 474 <tr valign="top"> … … 482 490 $site_blog_ids = $wpdb->get_col("SELECT blog_id FROM ".$wpdb->prefix."blogs"); 483 491 484 if ( is_array($site_blog_ids)) {492 if ( is_array( $site_blog_ids ) ) { 485 493 486 494 foreach( $site_blog_ids AS $site_blog_id ) { -
angry-creative-logger/trunk/plugin.php
r958139 r958566 4 4 Plugin URI: http://angrycreative.se 5 5 Description: Inspects and logs possible issues with your Wordpress installation. 6 Version: 0.5. 16 Version: 0.5.2 7 7 Author: Robin Björklund, Sammy Nordström, Angry Creative AB 8 8 */ 9 9 10 define( 'ACI_PLUGIN_VERSION', '0.5. 1' );10 define( 'ACI_PLUGIN_VERSION', '0.5.2' ); 11 11 12 12 define( 'ACI_PLUGIN_DIR', dirname( __FILE__ ) ); -
angry-creative-logger/trunk/readme.txt
r958139 r958566 4 4 Requires at least: 3.0.1 5 5 Tested up to: 3.9.1 6 Stable tag: 0.5. 16 Stable tag: 0.5.2 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.