Changeset 646871
- Timestamp:
- 01/02/2013 04:40:50 AM (13 years ago)
- Location:
- debug-this/trunk
- Files:
-
- 4 edited
-
_inc/css/debug-this.css (modified) (1 diff)
-
_inc/debug-template.php (modified) (1 diff)
-
_inc/extensions.php (modified) (2 diffs)
-
debug-this.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
debug-this/trunk/_inc/css/debug-this.css
r645456 r646871 41 41 text-decoration: none; 42 42 } 43 44 .header-links{ 45 margin-left:0; 46 } 47 48 .header-links li{ 49 list-style: none; 50 display:inline-block; 51 margin-right:10px; 52 border-right:1px solid #777; 53 padding-right:10px; 54 } 55 56 .header-links li:last-child{ 57 border:none; 58 } -
debug-this/trunk/_inc/debug-template.php
r646297 r646871 12 12 <body> 13 13 <div class='debug-this'> 14 <a href="/<?php echo Debug_This::get_escape_ link();?>" class="escape">x</a>14 <a href="/<?php echo Debug_This::get_escape_url();?>" class="escape">x</a> 15 15 <div class='debug'> 16 16 %DEBUG% -
debug-this/trunk/_inc/extensions.php
r646731 r646871 295 295 $debug = print_r($dropins, true); 296 296 else 297 $debug = __("No dropins found. To learn more, please see: <a href='http://hakre.wordpress.com/2010/05/01/must-use-and-drop-ins-plugins/'>http://hakre.wordpress.com/2010/05/01/must-use-and-drop-ins-plugins/</a>", 'debug-this');297 $debug = sprintf(__("No dropins found. To learn more, please see: %s", 'debug-this'), "<a href='http://hakre.wordpress.com/2010/05/01/must-use-and-drop-ins-plugins/'>http://hakre.wordpress.com/2010/05/01/must-use-and-drop-ins-plugins/</a>"); 298 298 return $debug; 299 299 } … … 742 742 743 743 public function wp_debug(){ 744 if(defined('WP_DEBUG') && WP_DEBUG !== true && defined('WP_DEBUG_LOG') && WP_DEBUG_LOG !== true){ 744 if(defined('WP_DEBUG') && WP_DEBUG === true && defined('WP_DEBUG_LOG') && WP_DEBUG_LOG === true){ 745 $path = WP_CONTENT_DIR.'/debug.log'; 746 $debug = ''; 747 if(file_exists($path) && is_writeable($path)){ 748 add_debug_header_link(Debug_This::get_current_debug_url().'&clear-debug-log=true', __('Reset log file', 'debug-this')); 749 if(isset($_GET['clear-debug-log'])){ 750 if(file_put_contents($path, '') === 0) 751 $debug .= __('Debug log was successfully cleared.', 'debug-this'); 752 else 753 $debug .= __('Debug log could not be reset. Please try again', 'debug-this'); 754 } 755 $debug .= file_get_contents($path); 756 if(!$debug) 757 $debug .= __('Looking good! No notices were logged.', 'debug-this'); 758 } 759 elseif(touch($path)) 760 $debug = __('Looking good! No notices were logged.', 'debug-this'); #Better reporting. If nothing was found, it's not a file perms error. 761 else 762 $debug = __('Could not open debug.log. Please make sure your wp-content folder is writeable by the web server user.', 'debug-this'); 763 return $debug; 764 } 765 else{ 745 766 $debug = __("Please add the following to wp-config.php to use this mode.\ndefine('WP_DEBUG', true);\ndefine('WP_DEBUG_LOG', true);\ndefine('WP_DEBUG_DISPLAY', false);", 'debug-this'); 746 767 return $debug; 747 768 } 748 $path = WP_CONTENT_DIR.'/debug.log';749 750 if(file_exists($path) && is_writeable($path)){751 $debug = file_get_contents($path);752 if(!$debug)753 $debug = __('Looking good! No notices were logged.', 'debug-this');754 file_put_contents($path, ''); #Clear contents for next page load755 }756 elseif(touch($path))757 $debug = __('Looking good! No notices were logged.', 'debug-this'); #Better reporting. If nothing was found, it's not a file perms error.758 else759 $debug = __('Could not open debug.log. Please make sure your wp-content folder is writeable by the web server user.', 'debug-this');760 return $debug;761 769 } 762 770 -
debug-this/trunk/debug-this.php
r646381 r646871 32 32 protected $description; 33 33 public static $mode; 34 p rotected$query_var = 'debug-this';34 public static $query_var = 'debug-this'; 35 35 public static $no_pre = false; 36 36 protected $default_mode = 'wp_query'; … … 39 39 public static $queries; 40 40 protected $nonce_action = 'dEbUg-ThIs'; 41 public static $debug_header; 41 42 42 43 public function __construct(){ … … 79 80 'defaultMode' => $this->default_mode, 80 81 'template' => $this->original_template, 81 'queryVar' => $this->query_var82 'queryVar' => self::$query_var 82 83 ); 83 84 wp_localize_script('debug-this', 'debugThis', $l10n); … … 86 87 87 88 public function add_query_var($vars){ 88 $vars[] = $this->query_var;89 $vars[] = "$this->query_var-fetch";90 $vars[] = "$this->query_var-key";91 $vars[] = "$this->query_var-ts";92 $vars[] = "$this->query_var-nonce";89 $vars[] = self::$query_var; 90 $vars[] = self::$query_var."-fetch"; 91 $vars[] = self::$query_var."-key"; 92 $vars[] = self::$query_var."-ts"; 93 $vars[] = self::$query_var."-nonce"; 93 94 return $vars; 94 95 } … … 103 104 protected function is_fetch(){ 104 105 if( 105 get_query_var( "$this->query_var-fetch") &&106 get_query_var( "$this->query_var-ts") &&107 get_query_var( "$this->query_var-key") &&108 get_query_var( "$this->query_var-nonce")106 get_query_var(self::$query_var."-fetch") && 107 get_query_var(self::$query_var."-ts") && 108 get_query_var(self::$query_var."-key") && 109 get_query_var(self::$query_var."-nonce") 109 110 ){ 110 $time = get_query_var( "$this->query_var-ts");111 $nonce = get_query_var( "$this->query_var-nonce");112 $key = get_query_var( "$this->query_var-key");111 $time = get_query_var(self::$query_var."-ts"); 112 $nonce = get_query_var(self::$query_var."-nonce"); 113 $key = get_query_var(self::$query_var."-key"); 113 114 114 115 //Security #1 - Time range … … 154 155 155 156 $fetch_vars = array( 156 "$this->query_var-fetch" => true,157 "$this->query_var-key" => md5($time . wp_salt('logged_in') . $nonce),158 "$this->query_var-ts" => $time,159 "$this->query_var-nonce" => $nonce157 self::$query_var."-fetch" => true, 158 self::$query_var."-key" => md5($time . wp_salt('logged_in') . $nonce), 159 self::$query_var."-ts" => $time, 160 self::$query_var."-nonce" => $nonce 160 161 ); 161 162 162 163 $query_vars = $wp->query_vars; 163 unset($query_vars[ $this->query_var]);164 unset($query_vars[self::$query_var]); 164 165 165 166 $vars = array_merge($fetch_vars, $query_vars); … … 194 195 195 196 protected function is_debug(){ 196 if(isset($_GET[ $this->query_var])){197 self::$mode = $_GET[ $this->query_var] ? $_GET[$this->query_var] : apply_filters('debug_this_default_mode', $this->default_mode);197 if(isset($_GET[self::$query_var])){ 198 self::$mode = $_GET[self::$query_var] ? $_GET[self::$query_var] : apply_filters('debug_this_default_mode', $this->default_mode); 198 199 return true; 199 200 } … … 228 229 $description = $this->description ? ' - '. $this->description : ''; 229 230 echo '<p>'.__('Debug This Mode', 'debug_this').': '.self::$mode.$description.'</p>'; 231 echo '<ul class="header-links">'.self::$debug_header.'</ul>'; 230 232 if(self::$no_pre) 231 233 echo $this->debug; … … 248 250 #Build out query string 249 251 $vars = $wp->query_vars; 250 $vars[ $this->query_var] = $this->default_mode;252 $vars[self::$query_var] = $this->default_mode; 251 253 $query_string = http_build_query($vars); 252 254 … … 260 262 foreach($extensions as $id => $values){ 261 263 #Update query string 262 $vars[ $this->query_var] = $id;264 $vars[self::$query_var] = $id; 263 265 $query_string = http_build_query($vars); 264 266 $wp_admin_bar->add_menu(array('id' => $id, 'parent' => $group, 'title' => $values['name'], 'href' => "?$query_string")); … … 284 286 } 285 287 286 public function get_escape_ link(){288 public function get_escape_url(){ 287 289 global $wp; 288 290 289 291 $permalinks = get_option('permalink_structure'); 290 292 if($permalinks) 291 $ link= $wp->request;293 $url = $wp->request; 292 294 else{ 293 295 $vars = $wp->query_vars; … … 295 297 if($v === self::$mode) 296 298 unset($vars[$k]); 297 $link = !empty($vars) ? '?' . http_build_query($vars) : ''; 298 } 299 return $link; 299 $url = !empty($vars) ? '?' . http_build_query($vars) : ''; 300 } 301 return $url; 302 } 303 304 public function get_current_debug_url(){ 305 $url = self::get_escape_url(); 306 $url .= '&'.self::$query_var.'='.self::$mode; 307 return $url; 300 308 } 301 309 … … 320 328 if(isset($_debugger_extensions[$id])) 321 329 unset($_debugger_extensions[$id]); 330 } 331 332 function add_debug_header_link($url, $label, $classes = ''){ 333 Debug_This::$debug_header = Debug_This::$debug_header."<li><a href='$url' class='$classes'>$label</a></li>"; 322 334 } 323 335
Note: See TracChangeset
for help on using the changeset viewer.