Changeset 225354
- Timestamp:
- 04/04/2010 10:27:43 PM (16 years ago)
- Location:
- wp-pear-debug/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (1 diff)
-
wp-pear-debug.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-pear-debug/trunk/readme.txt
r210592 r225354 4 4 Tags: debug, pear, php_debug, debugging, database debug, performance debug, performance 5 5 Requires at least: 2.8 6 Tested up to: 2.9. 17 Stable tag: 1.4. 66 Tested up to: 2.9.2 7 Stable tag: 1.4.7 8 8 9 9 This plugin incorporates the pear php_debug library into wordpress. -
wp-pear-debug/trunk/wp-pear-debug.php
r202102 r225354 6 6 * Author: Community Modder 7 7 * Plugin URI: http://www.communitymodder.com 8 * Version: 1.4. 68 * Version: 1.4.7 9 9 * ======================================================================= 10 10 */ 11 //include class loader and let the magic happen 12 //Loads class from format dir1.dirN.className 13 //className can be folder with same name as class 14 require_once(WP_PLUGIN_DIR.'/wp-pear-debug/lib/util/wpdutil.class.php'); 11 15 12 16 … … 69 73 //Configuration options for debug library 70 74 //These really should not change for wordpress needs 75 //Shis should probably be somewhere else 71 76 public static function getConf() 72 77 { … … 79 84 'enable_watch' => false, 80 85 'replace_errorhandler' => true, 81 'HTML_DIV_images_path' => self::url()."/ images",86 'HTML_DIV_images_path' => self::url()."/lib/PHP_Debug/images", 82 87 ); 83 88 } 84 //include a class file85 //neat way of loading classes relative to base folder86 public static function loadClass($sClassPath)87 {88 $aParts = explode(".",$sClassPath);89 $sFile = self::path()."/";90 $iCount = 0;91 92 foreach($aParts as $sPart )93 {94 if( $iCount != count($aParts)-1 )95 {96 $sFile.= $sPart."/";97 }98 else99 {100 $sFile.= $sPart.".class.php";101 break;102 }103 $iCount++;104 }105 106 if( file_exists($sFile) && !is_dir($sFile) )107 {108 include_once($sFile);109 }110 else111 {112 throw new Exception($sFile);113 }114 115 }116 //return instance of class from file117 public static function getClass($sClassPath)118 {119 self::loadClass($sClassPath);120 121 $aParts = explode(".",$sClassPath);122 $sClass = $aParts[count($aParts)-1];123 $oClass = new $sClass;124 //Use exisiting instance if possible125 if(method_exists($oClass,'singleton'))126 {127 $oClass = $oClass->singleton();128 }129 return $oClass;130 }131 89 132 90 //Class initialization … … 145 103 } 146 104 //register javascript 147 wp_register_script(self::WPD_JS, "".self::url()."/ js/html_div.js");105 wp_register_script(self::WPD_JS, "".self::url()."/lib/PHP_Debug/js/html_div.js"); 148 106 //register css 149 wp_register_style(self::WPD_CSS, "".self::url()."/ css/html_div.css");107 wp_register_style(self::WPD_CSS, "".self::url()."/lib/PHP_Debug/css/html_div.css"); 150 108 151 109 //Include debug output for admin … … 172 130 add_action('admin_init',array('wp_pear_debug','settings')); 173 131 132 //This needs to be standardized 133 //Adapted from sample so I am just happen that it works...for now 174 134 $plugin_dir = basename(dirname(__FILE__)); 175 //load language files 135 //load language files (internationalize me) 176 136 load_plugin_textdomain( 'wp-pear-debug', 'wp-content/plugins/' . $plugin_dir.'/lang', $plugin_dir.'/lang' ); 177 137 … … 180 140 //self::add("Begin Debugging"); 181 141 } 142 182 143 //not using globals 183 144 //use this to get single instance of debug class 184 //All this drama just to load one class library!185 145 public static function get() 186 146 { 187 147 //return current instance of the pear debug class 188 return self::getClass('PHP_Debug'); 148 //using utility class to load libraries 149 return wpdutil::getClass('PHP_Debug'); 150 189 151 } 190 152 … … 213 175 private static function _processQueries() 214 176 { 215 foreach( self::getDB()->queries as $query)177 foreach(wpdutil::getDB()->queries as $query) 216 178 { 217 self::get()->query('[ '.self::queryCaller($query[2]).' ] '.' [ '. self::toSeconds($query[1]).' '.__('seconds','wp-pear-debug').' ] '.$query[0]);179 self::get()->query('[ '.self::queryCaller($query[2]).' ] '.' [ '.wpdutil::toSeconds($query[1]).' '.__('seconds','wp-pear-debug').' ] '.$query[0]); 218 180 } 219 181 } … … 226 188 } 227 189 228 //Database data in millionseconds. Change to seconds before output to user. 229 public static function toSeconds($milli) 230 { 231 return $milli * 1000; 232 } 233 234 //don't ask...umm cause its pretty? 235 //This call provides a standard access method for the database 236 //May be a long way away but we might see the end of global wpdb 237 public static function getDB() 238 { 239 global $wpdb; 240 return $wpdb; 241 } 190 242 191 243 192 protected static function enabled() … … 325 274 } 326 275 327 //Add in admin options with link under settings "Debugger"328 //Indent this big mess? Thank wordpress for that...This should all be javascript276 //Add in admin options with link under settings "Debugger" 277 //Indent this big mess? Thank wordpress for that...This should all be javascript 329 278 public static function admin() 330 279 { … … 352 301 $aSettings = self::$settings; 353 302 //generate dynamic user role settings 354 foreach(get_option( self::getDB()->prefix . 'user_roles') as $key => $value)303 foreach(get_option(wpdutil::getDB()->prefix . 'user_roles') as $key => $value) 355 304 { 356 305 $aSettings[] = array('type'=> self::WPD_SETTING_ROLE, 'key' => $key); … … 373 322 } 374 323 375 //Print options page 376 public static function options() 377 { 378 324 //Print options page 325 public static function options() 326 { 327 328 ?> 329 <div class=wrap> 330 <form method="post" action="options.php"> 331 332 <h3><?php _e('Debugger Settings','wp-pear-debug') ?></h3> 333 <div> 334 <div class="postbox"> 335 336 337 338 <select name="<?php echo self::opt(self::WPD_STATUS);?>"> 339 <option value="<?php echo self::WPD_DISABLE;?>" <?php if( get_option(self::opt(self::WPD_STATUS))== self::WPD_DISABLE ) echo "selected"; ?> ><?php _e('Disable Debugging','wp-pear-debug') ?></option> 340 <option value="<?php echo self::WPD_ENABLE;?>" <?php if( get_option(self::opt(self::WPD_STATUS))== self::WPD_ENABLE ) echo "selected"; ?> ><?php _e('Enable Debugging','wp-pear-debug') ?></option> 341 </select> 342 343 344 </div> 345 <h3> <?php _e('Display Debug for Roles:','wp-pear-debug') ?></h3> 346 <div class="postbox"> 347 <table> 348 349 <?php 350 351 foreach(self::getSettingFeilds() as $sField): 352 353 //we only want settings for roles 354 if($sField['type'] != self::WPD_SETTING_ROLE): 355 continue; 356 endif; 357 358 359 ?> 360 <tr> 361 <td> 362 <strong><?php echo ucfirst($sField['def']); ?></strong> 363 </td> 364 <td> 365 <select name="<?php echo $sField['key']; ?>"> 366 <option value="<?php echo self::WPD_STATUS_DISABLE;?>" <?php if(get_option($sField['key'])== self::WPD_STATUS_DISABLE) echo "selected"; ?> > 367 <?php _e('Disable','wp-pear-debug','wp-pear-debug') ?> 368 </option> 369 <option value="<?php echo self::WPD_STATUS_FRONT;?>" <?php if(get_option($sField['key'])== self::WPD_STATUS_FRONT) echo "selected"; ?> > 370 <?php _e('Front End Only','wp-pear-debug') ?> 371 </option> 372 373 <? if($sField['def'] != self::WPD_GUEST_ROLE): ?> 374 <option value="<?php echo self::WPD_STATUS_ADMIN;?>" <?php if(get_option($sField['key'])== self::WPD_STATUS_ADMIN) echo "selected"; ?> > 375 <?php _e('Admin Only','wp-pear-debug') ?> 376 </option> 377 <option value="<?php echo self::WPD_STATUS_BOTH;?>" <?php if(get_option($sField['key'])== self::WPD_STATUS_BOTH) echo "selected"; ?> > 378 <?php _e('Admin & Front End','wp-pear-debug') ?> 379 </option> 380 <?php endif; ?> 381 </select> 382 383 </td> 384 </tr> 385 <?php endforeach; ?> 386 </table> 387 </div> 388 <?php 389 //output hidden fields for settings (sweet) 390 settings_fields(self::WPD_OPTIONS_GROUP); 379 391 ?> 380 <div class=wrap> 381 <form method="post" action="options.php"> 382 383 <h3><?php _e('Debugger Settings','wp-pear-debug') ?></h3> 384 <div> 385 <div class="postbox"> 386 387 388 389 <select name="<?php echo self::opt(self::WPD_STATUS);?>"> 390 <option value="<?php echo self::WPD_DISABLE;?>" <?php if( get_option(self::opt(self::WPD_STATUS))== self::WPD_DISABLE ) echo "selected"; ?> ><?php _e('Disable Debugging','wp-pear-debug') ?></option> 391 <option value="<?php echo self::WPD_ENABLE;?>" <?php if( get_option(self::opt(self::WPD_STATUS))== self::WPD_ENABLE ) echo "selected"; ?> ><?php _e('Enable Debugging','wp-pear-debug') ?></option> 392 </select> 393 394 395 </div> 396 <h3> <?php _e('Display Debug for Roles:','wp-pear-debug') ?></h3> 397 <div class="postbox"> 398 <table> 399 400 <?php 401 402 foreach(self::getSettingFeilds() as $sField): 403 404 //we only want settings for roles 405 if($sField['type'] != self::WPD_SETTING_ROLE): 406 continue; 407 endif; 408 409 410 ?> 411 <tr> 412 <td> 413 <strong><?php echo ucfirst($sField['def']); ?></strong> 414 </td> 415 <td> 416 <select name="<?php echo $sField['key']; ?>"> 417 <option value="<?php echo self::WPD_STATUS_DISABLE;?>" <?php if(get_option($sField['key'])== self::WPD_STATUS_DISABLE) echo "selected"; ?> > 418 <?php _e('Disable','wp-pear-debug','wp-pear-debug') ?> 419 </option> 420 <option value="<?php echo self::WPD_STATUS_FRONT;?>" <?php if(get_option($sField['key'])== self::WPD_STATUS_FRONT) echo "selected"; ?> > 421 <?php _e('Front End Only','wp-pear-debug') ?> 422 </option> 423 424 <? if($sField['def'] != self::WPD_GUEST_ROLE): ?> 425 <option value="<?php echo self::WPD_STATUS_ADMIN;?>" <?php if(get_option($sField['key'])== self::WPD_STATUS_ADMIN) echo "selected"; ?> > 426 <?php _e('Admin Only','wp-pear-debug') ?> 427 </option> 428 <option value="<?php echo self::WPD_STATUS_BOTH;?>" <?php if(get_option($sField['key'])== self::WPD_STATUS_BOTH) echo "selected"; ?> > 429 <?php _e('Admin & Front End','wp-pear-debug') ?> 430 </option> 431 <?php endif; ?> 432 </select> 433 434 </td> 435 </tr> 436 <?php endforeach; ?> 437 </table> 438 </div> 439 <?php 440 //output hidden fields for settings (sweet) 441 settings_fields(self::WPD_OPTIONS_GROUP); 392 393 </div> 394 <div class="submit"> 395 <input type="submit" name="Submit" value="<?php _e('Save Changes','wp-pear-debug') ?>" /> 396 </div> 397 398 </form> 399 </div> 400 401 <?php 402 } 403 404 405 406 } 407 408 409 410 411 412 442 413 ?> 443 444 </div>445 <div class="submit">446 <input type="submit" name="Submit" value="<?php _e('Save Changes','wp-pear-debug') ?>" />447 </div>448 449 </form>450 </div>451 452 <?php453 }454 455 456 457 }458 459 460 461 462 463 464 ?>
Note: See TracChangeset
for help on using the changeset viewer.