Title: code improvement suggestion
Last modified: August 20, 2016

---

# code improvement suggestion

 *  [Dwenaus](https://wordpress.org/support/users/dwenaus/)
 * (@dwenaus)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/code-improvement-suggestion/)
 * hi, thanks for the nice plugin. I have a suggestion to improve the code a bit.
   right now it produces lots of php errors when WP_DEBUG is set to true when creating
   a new widget. not a big deal but for those that have it turned on while doing
   development, the plugin is unusable.
 * in function form() instead of using `$instance["title"]` a better approach would
   be something like this:
 * `$title = isset( $instance["title"] ) ? $instance["title"] : '';`
 * using `isset()` or `! empty()` stops the debug errors for unset array elements.
   
   bonus: you can even set defaults if you wanted to.
 * [http://wordpress.org/extend/plugins/category-posts/](http://wordpress.org/extend/plugins/category-posts/)

Viewing 1 replies (of 1 total)

 *  [maxoud](https://wordpress.org/support/users/maxoud/)
 * (@maxoud)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/code-improvement-suggestion/#post-3226653)
 * It’s a bad practice to produce the code generatinge too many Notices as there
   is a probability to never recognize an important one.
 * One more point is that this plugin has been written when `WP_DEBUG == false` 
   so it’s impossible to entrust it and for that reason should be avoided.

Viewing 1 replies (of 1 total)

The topic ‘code improvement suggestion’ is closed to new replies.

 * ![](https://ps.w.org/category-posts/assets/icon-256x256.png?rev=1419008)
 * [Category Posts Widget](https://wordpress.org/plugins/category-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/category-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/category-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/category-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/category-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/category-posts/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [maxoud](https://wordpress.org/support/users/maxoud/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/code-improvement-suggestion/#post-3226653)
 * Status: not resolved