Changeset 188347
- Timestamp:
- 12/31/2009 03:32:45 AM (16 years ago)
- Location:
- wp-pear-debug/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (6 diffs)
-
wp-pear-debug.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-pear-debug/trunk/readme.txt
r150601 r188347 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. 8.47 Stable tag: 1.4 6 Tested up to: 2.9 7 Stable tag: 1.4.1 8 8 9 9 This plugin incorporates the pear php_debug library into wordpress. … … 31 31 For each you have the following options: Admin & Front End, Admin Only, Front End Only, Disable 32 32 4. The plugin shows queries that were run by wordpress 33 Please not that some queries run before the plugin is initialized33 Please note that some queries run before the plugin is initialized. to ensure most if not all queries get recorded see step 4 in installation section. v1.4.1 shows not only the query but the time taken by the query and the function which called the query. 34 34 5. You can easly add debug information to the debugger by making use of several functions 35 35 36 36 `<?php 37 37 //For advanced use. 38 //Direct access to instance of debugger 38 39 $oDebug = wp_pear_debug::get(); 39 40 $oDebug->add($variable); //add variable to debug … … 44 45 45 46 //With v1.2 you have access to several wrapper functions 47 //Enough for most people 46 48 wp_pear_debug::add(); 47 49 wp_pear_debug::dump(); 48 50 wp_pear_debug::error(); 49 wp_pear_debug::queryRel(); 51 //if you actually run this query using wpdb 52 //It will probably appear anyways. 53 wp_pear_debug::query(); 50 54 51 55 … … 71 75 * Link to w3c validator 72 76 10. With v1.2 you can add debug information via shortcode from within your post. 77 `[wp_pear_debug]foo bar[/wp_pear_debug]` 78 `[wp_pear-debug foo="bar" foo1="bar2"]` 73 79 74 80 75 81 == Installation == 76 82 77 Please note that v1.3 works up to wordpress version 2.8. However, I cannot guarantee v1.4 below version 2.8 78 because of the use of new hooks and methods. In using version 1.3 you are not foregoing any new features so please download 79 the appropriate version. 83 Please note that v1.3 works up to wordpress version 2.8. However, I cannot guarantee v1.4.1 below version 2.8 84 From version 1.4.1 and version 5 there will be features not present in v1.3 such as database query execution time and database query back trace. 80 85 81 86 File list … … 92 97 2. Activate the plugin through the 'Plugins' menu in WordPress 93 98 3. Set the appropriate option under settings->Debugger admin menu 99 4. The following step is optional but recommended. Add the following code to wp-config.php `define('SAVEQUERIES',true);` 94 100 95 101 == Frequently Asked Questions == … … 122 128 123 129 == Interesting Points == 130 This plugin is completely encapsulated. This means that all functionality is hidden within the static wp_pear_debug class. This is important because it allows convenient naming of methods while avoiding conflicts. 124 131 125 Since the plugin is wrapped in a class it can easily be extended to add more functionality.126 The most promising possibility I have seen is the add_filter() method which I used to get the query information in the debug.127 Though I have not tested this thoroughly but the library also allows you to watch variables.128 132 -
wp-pear-debug/trunk/wp-pear-debug.php
r188343 r188347 6 6 * Author: Community Modder 7 7 * Plugin URI: http://www.communitymodder.com 8 * Version: 1.4 8 * Version: 1.4.1 9 9 * ======================================================================= 10 10 */ … … 32 32 const WPD_CSS = 'wp_pear_debug_css'; 33 33 34 35 36 34 //Definitions 37 35 const WPD_GUEST_ROLE = 'guest'; … … 44 42 } 45 43 46 //return the path to the plugin fold 44 //return the path to the plugin folder 47 45 private static function path() 48 46 { … … 97 95 { 98 96 $sFile.= $sPart.".class.php"; 99 100 97 break; 101 102 98 } 103 99 $iCount++; … … 111 107 { 112 108 throw new Exception($sFile); 113 114 } 115 116 } 117 //return instance of class 109 } 110 111 } 112 //return instance of class from file 118 113 public static function getClass($sClassPath) 119 114 { … … 127 122 { 128 123 $oClass = $oClass->singleton(); 129 130 } 131 124 } 132 125 return $oClass; 133 134 126 } 135 127 … … 140 132 $sDebug = self::enabled(); 141 133 142 143 134 if($sDebug) 144 135 { 145 136 //Instruct wordpress to save queries 146 //Please do this in wp-config.php instead 147 define('SAVEQUERIES',true); 137 //If not set in wp-config.php then set. Keep in mind we may miss some queries as a result 138 if(!defined('SAVEQUERIES') || !SAVEQUERIES) 139 { 140 define('SAVEQUERIES',true); 141 } 148 142 //register javascript 149 143 wp_register_script(self::WPD_JS, "".self::url()."/js/html_div.js"); … … 166 160 } 167 161 168 //unlimited possibilities for add_filter and this plugin169 add_filter('query',array('wp_pear_debug','query'));170 162 //Enable shortcode debug entry point 171 163 add_shortcode('wp_pear_debug', array('wp_pear_debug','short')); … … 186 178 { 187 179 //Add query info before render 188 //This new method should gather most if not all the query info 180 //This method should gather most if not all the query info 181 //Use define('SAVEQUERIES',true); in wp-config.php for best results 189 182 self::_processQueries(); 190 183 //Render debug information … … 208 201 foreach(self::getDB()->queries as $query) 209 202 { 210 self::get()->query('[ function:'.self::queryCaller($query[2]).' ] '.' [ '.self::toSeconds($query[1]).' secs ] '.$query[0]);203 self::get()->query('[ '.self::queryCaller($query[2]).' ] '.' [ '.self::toSeconds($query[1]).' secs ] '.$query[0]); 211 204 } 212 205 } … … 242 235 Get option automatically creates options that are non existent 243 236 Therefore the initial state of the plugin will be the desired effect where all options are disabled 244 Hence the absence of an installer 237 Hence the absence of an installer. 238 Ok...Installer coming in version 1.5 when more options are added. 245 239 ******/ 246 240 if( get_option( self::opt( self::WPD_STATUS) ) == self::WPD_ENABLE ) … … 262 256 if( is_numeric(get_option(self::opt($role))) ) 263 257 { 258 return get_option(self::opt($role)); 259 } 260 261 } 262 else 263 { 264 return false; 265 } 266 267 264 268 265 return get_option(self::opt($role)); 266 267 } 268 269 } 270 271 //wrapper functions 272 //Library contains more functionality but these are essentials 273 //Add plain text message 274 public static function add($sVar) 275 { 276 self::get()->add($sVar); 277 } 278 279 //add array like print_r or array item like $foo['bar'] 280 public static function dump($obj, $varName = '') 281 { 282 self::get()->dump($obj, $varName); 283 } 284 285 //Database related info 286 public static function queryRel($sInfo) 287 { 288 self::get()->queryRel($sInfo); 289 } 290 291 //Your own generated error 292 public static function error($sInfo) 293 { 294 self::get()->error($sInfo); 295 } 296 297 //shortcode entry point to debug 298 //Useful for debugging other short codes 299 //Usage: [wp_pear_debug]foo bar[/wp_pear_debug] 300 //Usage: [wp_pear-debug foo="bar" foo1="bar2"] 301 public static function short($atts,$sContent='') 302 { 303 if( isset($sContent) && !empty($sContent) ) 304 { 305 self::add($sContent); 269 306 } 270 307 else 271 308 { 272 return false; 273 } 274 275 276 277 } 278 279 //wrapper functions 280 //Library contains more functionality but these are essentials 281 282 public static function add($sVar) 283 { 284 self::get()->add($sVar); 285 } 286 public static function dump($obj, $varName = '') 287 { 288 self::get()->dump($obj, $varName); 289 } 290 public static function queryRel($sInfo) 291 { 292 self::get()->queryRel($sInfo); 293 } 294 public static function error($sInfo) 295 { 296 self::get()->error($sInfo); 297 } 298 //shortcode entry point to debug 299 //Does not return anything 300 //Picks up data from post content 301 //Have no idea what this can be used for! lol! 302 public static function short($atts,$sContent='') 303 { 304 305 if( isset($sContent) && !empty($sContent) ) 306 { 307 self::add($sContent); 308 } 309 else 310 { 311 self::dump($atts); 312 } 313 } 309 self::dump($atts); 310 } 311 } 314 312 315 313 //Add in admin options with link under settings "Debugger" 316 314 //Indent this big mess? Thank wordpress for that...This should all be javascript 317 public static function admin() 318 { 319 320 add_options_page('Debugger Options', 'Debugger', 10, '/wp-pear-debug/'.basename(__FILE__),array('wp_pear_debug','options')); 321 } 322 323 315 public static function admin() 316 { 317 add_options_page('Debugger Options', 'Debugger', 10, '/wp-pear-debug/'.basename(__FILE__),array('wp_pear_debug','options')); 318 } 319 320 //Do I hear multi language? ha! 324 321 public static function options() 325 322 {
Note: See TracChangeset
for help on using the changeset viewer.