Support » Plugins and Hacks » Category Posts Widget » code improvement suggestion

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.


Viewing 1 replies (of 1 total)
  • 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.