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( 'secure_auth_redirect',...


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

Turn off WP_DEBUG because it overwrite your ini_set.


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', false)...


4

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

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

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

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

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

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

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 wp-...


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

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

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

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

However, if you really want to display errors and not store them in log file (like I wanted), then you can turn on debugging for your Public IP like following - if ( $_SERVER['REMOTE_ADDR'] == 'xxx.xxx.xxx.xxx') define('WP_DEBUG', true); There should not be a problem as long as you are on Static IP, but if you have dynamic IP, you probably can change the ...


1

To make sure that the index.php will be loaded first add the following line to your .htaccess: DirectoryIndex index.php index.html This tells Apache to ignore an index.html if an index.php exists.


1

Because I somehow dropped a file called "index.html" in my WordPress install. How'd I find out? I created a completely fresh installation and used diff to compare them.


1

What you're looking for is the Log Deprecated Notices plugin. (Don't run it on a production site, as it is a direct-to-database log.) What it'll do is convert those cryptic messages that are likely to reference has_cap() or some line in functions.php, to what's actually going on. The Debug Bar plugin is also nice. It tracks notices of that pageload, using ...


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.


1

Just install the Log Deprecated Notices plugin.


1

Replace define('WP_DEBUG', false); with this: ini_set('log_errors','On'); ini_set('display_errors','Off'); ini_set('error_reporting', E_ALL ); define('WP_DEBUG', false); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false);



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