Hot answers tagged

14

I don't think there is a universal URL hook. There are a lot of hooks and I may have missed it, but I don't think there is one. You can look through the hooks at adambrown.info. There are a lot of URL hooks, but not a universal one. If I may suggest another solution: Log the errors to a files. /** * This will log all errors notices and warnings to a file ...


9

In wp-config.php: if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) define( 'WP_DEBUG', false ); else define( 'WP_DEBUG', true );


8

Even though my first approach was for the garbage bin and s_ha_dums answer is a clean, and probably the best, way of going about it, let me offer one more working scenario: The following sets a cookie that is valid for the next 24 hours (86400 seconds) when an administrator logs into the system. In wp-config.php, the constant WP_DEBUG is conditionally ...


5

There are multiple tools and possibilities, and shure it would be nice to have something quick at hand. I know plugin authors who do offer debug flags so you can analyze what's going on quite easy. As for plugins, I have not tested it but looked at some screenshots and it is at least informative: Debug Bar (Wordpress Plugin) and the BlackBox Debug Bar ...


5

You have a lot of issues here. Stay away from defining globals and constants if you can. The global scope is an evil place to be. WordPress has made a huge mess of the global scope already, don't make it a bigger mess than it already is. You can make use a static variable inside your function/filter Avoid using TEMPLATEPATH. You should use ...


4

I don’t know how to move the notices to the bottom or if that’s possible at all. To disable the debug mode in wp-admin write in wp-config.php: define( 'WP_DEBUG', FALSE === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/' ) ); Untested: You could try to enable warnings in admin with: // happens early in wp-admin/admin.php add_filter( ...


4

Turn off WP_DEBUG because it overwrite your ini_set.


4

WordPress logic forces WP_DEBUG to be defined to something, even if it's omitted it will be set to false in wp_initial_constants() during load. However "background" (that is not when it is checked explicitly) function of WP_DEBUG is to be a flag for how PHP error reporting should be configured on runtime. That configuration is performed by wp_debug_mode() ...


4

When WP_DEBUG is set, WordPress sets (via wp_debug_mode() call early in core load process) the error reporting level to E_ALL & ~E_DEPRECATED & ~E_STRICT. This means all warnings and errors except strict errors and PHP deprecated functions (not WordPress ones). You can define your own level in a custom mu-plugin (the override needs to be called as ...


4

You can do this by adding some code to wp-config.php $request_uri = $_SERVER['REQUEST_URI']; $debug_dirs = array ('/debug-dir1/','/debug-dir2/'); // list of directories to turn on debugging foreach ($debug_dirs as $debug_dir) { if (!strncmp($request_uri,$debug_dir,strlen($debug_dir))) { define('WP_DEBUG', true); } } define('WP_DEBUG', ...


3

PHP constants don't have the leading $. Strictly, this isn't WordPress, but since there isn't a Core is_debug() function that I am aware of, what you want is: if (defined('WP_DEBUG') && true === WP_DEBUG) { echo 'd00d'; }


3

It doesn't answer your question precisely, but from personal experience I found it is better to enable debug mode by matching IP address instead of URL. That requires to modification of links and solves how to identify admin before WP loads required user functionality.


3

It is not possible to turn on WP_DEBUG because it's defined in wp-config.php by default, redefinition of defined constants is not possible in PHP. If you want to keep them out of wp-config.php ask them to add to the top something like: if ( file_exists( 'safe-wp-config.php' ) ) { /* this will contains WP_DEBUG */ include 'safe-wp-config.php'; } ...


2

You have several tools at your disposal when working with native WordPress debugging. PHP Debugging - WP_DEBUG is the native WordPress PHP constant for debugging WordPress errors. It sets PHP's error reporting to to E_ALL for warnings when deprecated functions are used and if none are found it sets it to E_ALL ^ E_NOTICE ^ E_USER_NOTICE. So most of the ...


2

I've used Theme Check in the past and found it very good. If I recall correctly, it checks against deprecated functions but most of all it suggests better functions to future-proof your theme, and alerts you when you're forgetting to implement features which WordPress' users have learnt to rely on.


2

If $query->query_vars['suppress_filters'] is not set you will get that message. Use empty($query->query_vars['suppress_filters']) instead of false == $query->query_vars['suppress_filters'] ) or use $query->get('suppress_filters') like this false == $query->get('suppress_filters'). Untested (minimally tested) but I believe either of those ...


2

A little bit of simple debugging and everything is clear. $REQUEST['action'] is set in this case, so my first guess wasn't true, but... Its value is 'save' and not 'page' nor 'reset'. So your code does exactly nothing, because there is no if part for such value;


2

Add var_dump($value); at the beggining of this loop. I'm pretty sure that not all options have id property and it may be some other bug... To get rid of these notices, your code should look like so: foreach ($options as $value) { if ( array_key_exists('id', $value) ) { if (isset($_REQUEST[ $value['id'] ] ) ) { //#997 update_option( ...


2

You could add following code (if not done already) in wp-config.php (please make a backup first of this file): define('WP_DEBUG', true); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ); This way debug is activated but the results (if have errors/notices) will not be shown but will be saved in a logfile which you can find then in ...


2

A note about the actual message you're getting from PHP. When you define a constant, you should do it with a string. define(SINGLE_PATH, TEMPLATEPATH.'/single/'); The first parameter is the constant name - when you call define the constant doesn't exist yet. This would take care of the message from PHP: define('SINGLE_PATH', TEMPLATEPATH.'/single/'); ...


1

Reference : Debugging in wordpress If you are looking for style these debug message then you should have these class for style. Set style as you wish by class that you need. And if you don't want show these wording but continue debug then you need to use WP_DEBUG_LOG and WP_DEBUG_DISPLAY. Below point that you need to perform to achieve debug log file. ...


1

You can simply use var_dump() to do this. That is how I check values inside functions and filters. I have the following line of code in a file which I simply copy and paste where needed to dump the value of a variable ?><pre><?php var_dump( $variable_to_test ); ?></pre><?php The pre tags dump a nice readable array/object/string ...


1

File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls. The WordPress coding styles require that you make use of the WP Filesystem instead of using direct PHP file functions. You can replace your file_get_contents call easily with: $response = wp_remote_get($feed_url); $file_content = $response['body']; For more ...


1

Just take a look at its source: function wp_debug_mode() { if ( WP_DEBUG ) { error_reporting( E_ALL ); if ( WP_DEBUG_DISPLAY ) ini_set( 'display_errors', 1 ); elseif ( null !== WP_DEBUG_DISPLAY ) ini_set( 'display_errors', 0 ); if ( WP_DEBUG_LOG ) { ini_set( 'log_errors', 1 ); ...


1

You should not need to call wp_debug_mode() yourself, it's called very early in the process of wp-settings.php. Perhaps you are defining the WP_DEBUG constant too late? It should be defined in the wp-config.php file, not anywhere else.


1

Any messages you are seeing with the debug output should be resolved. These often point to holes in the current logic within your theme. If your goal is to submit the theme to the WordPress Theme Directory you have to resolve any PHP errors, warnings, or notices for the theme to be approved. Themes must not generate any Theme-Check Warning or ...


1

"How can I prevent unexpected output from reaching the browser/interfering with my AJAX response?" The Problem Something in your installation is generating "unexpected output," that is, it's creating content or data which should not be there if WordPress is running smoothly. This could imply a misconfigured server environment, a faulty WordPress ...


1

Themes are required to use add_theme_page() in the Wordpress Theme Directory. You need: add_theme_page( $this->strings['page_title'], // Page title $this->strings['menu_title'], // Menu title 'edit_theme_options', // Capability $this->menu, // Menu slug array( ...


1

This issue has been reported here : trac Sometimes, HTTP requests fail. In this case, in particular, on localhost. That's part of the reason why we suppress them. I've personally never seen this. I think it's isolated to this server configuration. (Nacin)


1

The quickest way to do this is just using grep for the function name in it's theme/plugin folder. If your on windows you can use grepWin or agent ransack/powershell, etc. Also install debug-bar, it's a lot nicer to look at.



Only top voted, non community-wiki answers of a minimum length are eligible