How to debug a blank page?

Notice: wpdb::escape is deprecated since version 3.6! Use wpdb::prepare() or esc_sql() instead. in /nfs/c01/h04/mnt/38315/domains/joao.pt/html/wp-includes/functions.php on line 2905 WordPress often is not really accurate with giving your information. You can change that: Set error_reporting( -1 ); and define( ‘WP_DEBUG’, true );. More info in that Gist. This will avoid the white screen of death. If you … Read more

How to dump/log default values that are passed to hooks/filter functions?

If you want to keep your log on the server, try using php’s error_log() which is more flexible than just writing to files on disk. Something along the lines of: add_filter(‘manage_edit-member_columns’, ‘set_custom_edit_member_columns’); function set_custom_edit_member_columns($columns) { error_log(print_r($columns,true),3,__DIR__.”/log.txt”); $columns[‘photo’] = “Photo”; return $columns; } OTOH, if you find the browser console more convenient, you should include a … Read more

Debugging with functions.php

You can use var_dump() instead of print_r() – you get the type and the value of the variable and it will also work when your variable holds FALSE or NULL. print_r( false ); # doesn’t output anything var_dump( false ); # output: bool(false) print_r( NULL ); # doesn’t output anything var_dump( NULL ); # output: … Read more

debugging wp_cron jobs with XDebug in Eclipse

I just found the answer to my question over on stackoverflow…and thought I’d copy the answer over here for future reference since WP folks are probably more likely to look here. When WP_Cron fires a scheduled job it does so via a call to wp_remote_post(). The trick in that answer is to hook into cron_request … Read more

How to implement Sentry on WordPress? [closed]

For php I used this guide: https://cloudpresshosting.co.uk/blog/reporting-wordpress-errors-to-sentry For JS, I found out I can take the code of the bundle and the initialization and put in the header, using “add scripts to header and footer” plugin. https://wordpress.org/plugins/header-and-footer-scripts It took me time to notice I can’t put the initialization within the bundle import. Got something like … Read more

how to trace notice warning on core function is_page() & is_singular in class-wp-query.php

You can create your own custom error handler and add stack trace to your error log. set_error_handler(‘wpse_288408_handle_error’); function wpse_288408_handle_error( $errno, $errstr, $errfile, $errline ) { if( $errno === E_USER_NOTICE ) { $message=”You have an error notice: “%s” in file “%s” at line: “%s”.” ; $message = sprintf($message, $errstr, $errfile, $errline); error_log($message); error_log(wpse_288408_generate_stack_trace()); } } // … Read more

if(!is_user_logged_in()) returns true when 404

Please try this for your redirect: add_action( ‘template_redirect’, function(){ // no non-authenticated users allowed if( ! is_user_logged_in() ) { wp_redirect( home_url( ‘/wp-login.php’ ), 302 ); exit(); } }); to allow only logged in users to view your site. It’s generally too late to use redirect directly in the header.php file, so it’s better to use … Read more

How to debug php code in hostgator cPanel

PHP errors are the cause of whitescreens. You will have error logs in your Cpanel at Hostgator, but it’s much easier to use the debug logs that are available in WordPress. (For debugging outside of the WordPress environment, see http://php.net/manual/en/debugger-about.php about PHP’s own debugger and third-party debuggers). And, there are several other debugging methods you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)