Changeset 201945
- Timestamp:
- 02/04/2010 09:22:13 PM (16 years ago)
- Location:
- wp-pear-debug/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
wp-pear-debug.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-pear-debug/trunk/readme.txt
r194508 r201945 5 5 Requires at least: 2.8 6 6 Tested up to: 2.9.1 7 Stable tag: 1.4. 27 Stable tag: 1.4.5 8 8 9 9 This plugin incorporates the pear php_debug library into wordpress. … … 17 17 18 18 Please feel free to discuss it [here:](http://www.communitymodder.com/Released-wordpress-plugins/wp-pear-debug-wordpress-plugin.html) Plugin Home. 19 20 If you have used this plugin and it works please rate it and report the version of wordpress and the plugin version you are using. 19 21 20 22 Unfortunately php_debug only works in php5 so this plugin will only work in php5. Also, the plugin makes use of php5 specific code in its own class. -
wp-pear-debug/trunk/wp-pear-debug.php
r194373 r201945 6 6 * Author: Community Modder 7 7 * Plugin URI: http://www.communitymodder.com 8 * Version: 1.4. 28 * Version: 1.4.5 9 9 * ======================================================================= 10 10 */ … … 35 35 const WPD_GUEST_ROLE = 'guest'; 36 36 const WPD_STATUS = 'status'; 37 38 //shortcut for getting and setting distinct option name 39 protected static function opt($suffix) 40 { 41 return self::WPD_PREFIX.$suffix; 42 } 37 const WPD_OPTIONS_GROUP = 'wp_pear_debug_options'; 38 const WPD_SETTING_ROLE = 2; 39 const WPD_SETTING_MAIN = 1; 40 41 //Array for options handler. Define static options and their types 42 //WIll be useful in dynamic options builder in possibly 1.5 43 protected static $settings = array( 44 array('type'=> self::WPD_SETTING_ROLE,'key'=> self::WPD_GUEST_ROLE), 45 array('type'=> self::WPD_SETTING_MAIN,'key'=> self::WPD_STATUS) 46 ); 43 47 44 48 //return the path to the plugin folder … … 165 169 //add options page to the admin menu 166 170 add_action('admin_menu',array('wp_pear_debug','admin')); 171 //Register settings for options page 172 add_action('admin_init',array('wp_pear_debug','settings')); 167 173 } 168 174 //not using globals … … 180 186 //This method should gather most if not all the query info 181 187 //Use define('SAVEQUERIES',true); in wp-config.php for best results 182 self:: processQueries();188 self::_processQueries(); 183 189 //Render debug information 184 190 self::get()->display(); … … 197 203 198 204 //add all available query data to debug 199 private static function processQueries()205 private static function _processQueries() 200 206 { 201 207 foreach(self::getDB()->queries as $query) … … 206 212 207 213 //May have to test for array result but doubtful 208 p rivatestatic function queryCaller($callers)214 public static function queryCaller($callers) 209 215 { 210 216 $aCallers = explode(',',$callers); … … 213 219 214 220 //Database data in millionseconds. Change to seconds before output to user. 215 p rivatestatic function toSeconds($milli)221 public static function toSeconds($milli) 216 222 { 217 223 return $milli * 1000; … … 221 227 //This call provides a standard access method for the database 222 228 //May be a long way away but we might see the end of global wpdb 223 p rivatestatic function getDB()229 public static function getDB() 224 230 { 225 231 global $wpdb; … … 317 323 add_options_page('Debugger Options', 'Debugger', 10, '/wp-pear-debug/'.basename(__FILE__),array('wp_pear_debug','options')); 318 324 } 325 326 327 328 //shortcut for getting and setting distinct option name 329 protected static function opt($suffix) 330 { 331 return self::WPD_PREFIX.$suffix; 332 } 333 334 //convert array of option names to add prefix: destinct name 335 private static function opt_item(&$item,$key) 336 { 337 $item = array('type' => $item['type'], 'key' => self::opt($item['key']), 'def' => $item['key']); 338 } 339 340 //Return list of settings for plugin 341 private static function getSettingFeilds() 342 { 343 //get our static settings 344 $aSettings = self::$settings; 345 //generate dynamic user role settings 346 foreach(get_option(self::getDB()->prefix . 'user_roles') as $key => $value) 347 { 348 $aSettings[] = array('type'=> self::WPD_SETTING_ROLE, 'key' => $key); 349 } 350 //add wpd prefix to each setting name 351 array_walk($aSettings,array('wp_pear_debug','opt_item')); 352 353 //Here you go. All the settings we need to update 354 return $aSettings; 355 356 } 357 358 public static function settings() 359 { 360 foreach(self::getSettingFeilds() as $settingsField) 361 { 362 //Leave intval callback for now as all settings are integers 363 register_setting( self::WPD_OPTIONS_GROUP , $settingsField['key'], 'intval' ); 364 } 365 } 319 366 320 367 //Do I hear multi language? ha! … … 325 372 <div class=wrap> 326 373 <form method="post" action="options.php"> 327 <?php wp_nonce_field('update-options'); ?>328 374 329 375 <h3>Debugger Settings</h3> … … 343 389 <div class="postbox"> 344 390 <table> 345 <tr> 346 <td > 347 348 <strong>Guests</strong> 349 </td> 350 <td> 351 <select name="<?php echo self::opt(self::WPD_GUEST_ROLE); ?>"> 352 <option value="<?php echo self::WPD_STATUS_DISABLE;?>" <?php if(get_option(self::opt(self::WPD_GUEST_ROLE)) == self::WPD_STATUS_DISABLE) echo "selected"; ?> >Disable</option> 353 <option value="<?php echo self::WPD_STATUS_FRONT;?>" <?php if(get_option(self::opt(self::WPD_GUEST_ROLE)) == self::WPD_STATUS_FRONT) echo "selected"; ?> >Front End Only</option> 354 </select> 355 </td> 356 </tr> 391 357 392 <?php 358 $sKeys = self::opt(self::WPD_GUEST_ROLE).",".self::opt(self::WPD_STATUS); 359 foreach(get_option(self::getDB()->prefix . 'user_roles') as $key => $value) 360 { 361 //define the role key for options 362 $role_opt = self::opt($key); 393 394 foreach(self::getSettingFeilds() as $sField): 395 396 //we only want settings for roles 397 if($sField['type'] != self::WPD_SETTING_ROLE): 398 continue; 399 endif; 400 401 363 402 ?> 364 403 <tr> 365 404 <td> 366 <strong><?php echo ucfirst($ key); ?></strong>405 <strong><?php echo ucfirst($sField['def']); ?></strong> 367 406 </td> 368 407 <td> 369 <select name="<?php echo $role_opt ?>"> 370 <option value="<?php echo self::WPD_STATUS_DISABLE;?>" <?php if(get_option($role_opt)== self::WPD_STATUS_DISABLE) echo "selected"; ?> >Disable</option> 371 <option value="<?php echo self::WPD_STATUS_FRONT;?>" <?php if(get_option($role_opt)== self::WPD_STATUS_FRONT) echo "selected"; ?> >Front End Only</option> 372 <option value="<?php echo self::WPD_STATUS_ADMIN;?>" <?php if(get_option($role_opt)== self::WPD_STATUS_ADMIN) echo "selected"; ?> >Admin Only</option> 373 <option value="<?php echo self::WPD_STATUS_BOTH;?>" <?php if(get_option($role_opt)== self::WPD_STATUS_BOTH) echo "selected"; ?> >Admin & Front End</option> 408 <select name="<?php echo $sField['key']; ?>"> 409 <option value="<?php echo self::WPD_STATUS_DISABLE;?>" <?php if(get_option($sField['key'])== self::WPD_STATUS_DISABLE) echo "selected"; ?> >Disable</option> 410 <option value="<?php echo self::WPD_STATUS_FRONT;?>" <?php if(get_option($sField['key'])== self::WPD_STATUS_FRONT) echo "selected"; ?> >Front End Only</option> 411 412 <? if($sField['def'] != self::WPD_GUEST_ROLE): ?> 413 <option value="<?php echo self::WPD_STATUS_ADMIN;?>" <?php if(get_option($sField['key'])== self::WPD_STATUS_ADMIN) echo "selected"; ?> >Admin Only</option> 414 <option value="<?php echo self::WPD_STATUS_BOTH;?>" <?php if(get_option($sField['key'])== self::WPD_STATUS_BOTH) echo "selected"; ?> >Admin & Front End</option> 415 <?php endif; ?> 374 416 </select> 375 <?php 376 $sKeys.=','.$role_opt.""; 377 } 378 ?> 417 379 418 </td> 380 419 </tr> 420 <?php endforeach; ?> 381 421 </table> 382 422 </div> 383 <input type="hidden" name="action" value="update" /> 384 <input type="hidden" name="page_options" value="<?php echo $sKeys; ?>" /> 423 <?php 424 //output hidden fields for settings (sweet) 425 settings_fields(self::WPD_OPTIONS_GROUP); 426 ?> 385 427 386 428 </div>
Note: See TracChangeset
for help on using the changeset viewer.