X

Plugin Development Best Practices: How to Display Error Messages

Snippets by IsItWP

While developing a plugin, you might want to display error messages if something went terribly wrong such as if the user’s version of PHP is too old. You can use WordPress built-in function wp_die(), which creates a better looking error message, in which we can provide helpful links etc.

The function wp_die() is designed to give output just before it dies to avoid empty or time-outing responses.

Instructions:

Place it in your plugin’s code wherever you want to stop the plugin and show an error message.

<?php wp_die( __("Your PHP version isn't up-to-date, please <a href='http://php.net'>update</a>.") ); ?>

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!
[60% OFF Today!]
[60% OFF Today!]
[10% OFF Today!]
[10% OFF Today!]
[50% OFF Today!]
[50% OFF Today!]