Articles of error handling

Auto-detect javascript errors and warn theme user

This may sound simple, but it’s not 🙂 What I want, and most likely many theme developers do (themes that use javascript / jquery), is to warn the theme user that his site has javascript errors. In my themes at least, in about 95% of these error situations, the problem comes from outdated / badly-written […]

How to make my plugin code die gracefully

I’ve set up a class for my function, and I’d like to implement some form of error handling. But I’m new to this error handling lark. Can I set_error_handler to only show certain messages (and can these be as wordpress alerts in the admin section)? And if there is a fatal error in my plugin […]

Handling duplicates with wp_insert_term()

I’m using wp_insert_term which works quite well Now I want some error handler for when using the same name. $term_id = wp_insert_term( $term, ‘wpsc_product_category’, $args ); if($term_id) {//my operations here} where $term = $_POST[‘categoryTitle’]; I want to display some error when such name already exists. In wp_insert_term, how to check if this $term_id is duplicate? […]

Add error message on password protected pages

Is there a way to add an “incorrect password” error message on password protected pages? I’ve looked everywhere and the closest thing I can find is from here: Add error message on password protected page The problem is that the error persists even when you navigate away from the page because it’s based on cookies. […]

Suppress deprecated notices

When I use: define(‘WP_DEBUG’, 1); In my wp-config.php, it works fine, but I am hacking an old theme and I would like to suppress deprecated notices. My understanding is that adding this: error_reporting( E_ERROR | E_NOTICE | E_PARSE ) Should do the trick. I have added it to wp-config.php and to header.php in my theme. […]

Why $wpdb->show_errors() and print_error() is showing an output even if the query output is correct?

In order of figuring out the following issue, see https://wordpress.stackexchange.com/questions/178995/sanitize-a-working-query-string-by-using-wpdb-prepare-fails-with-mysql-db-er i ran into an rather odd behaviour. Even that my used query was correct and showing the right output. global $wpdb; $wpdb->show_errors(); $pageposts = $wpdb->get_results( $wpdb->prepare( ” SELECT skposts.* FROM $wpdb->posts skposts, $wpdb->postmeta skpostmeta1, $wpdb->postmeta skpostmeta2 WHERE skposts.ID = skpostmeta1.post_id AND skposts.ID = skpostmeta2.post_id AND […]

How to show an error message after publishing a post?

I’m using the transition_post_status hook to perform some operations after publishing a post. In some conditions I would like to show an error message in a red box under “Edit Post” and above “Post published”: How can I do that?

WordPress PHP error handling and reporting in production environment

I’m trying to find a solution on how to handle the displaying and logging of errors in a PHP (WordPress) production environment. Is it possible to do the following (alternative suggestions welcome): Capture critical errors and send immediate email notification (this looks like a promising solution, but haven’t tested in my production env yet). Don’t […]

How to log mysql errors from wordpress core?

I am developing a wordpress site and I would like to be able to log and handle mysql errors from wordpress core. My site has a mix of wordpress pages and posts + a few php pages that run under the wordpress engine. I configured the php.ini to prepend a php file to all php […]

Showing WP_Error message with admin_notice action hook

I have just get an answer to one of my question but the problem is I want to print an error when every user will insert tags of more than two words through post-new.php with admin_notice action hook. How can it be done?