Title: Develop with Debug Turned On
Last modified: August 11, 2017

---

# Develop with Debug Turned On

 *  Resolved [Chad Butler](https://wordpress.org/support/users/cbutlerjr/)
 * (@cbutlerjr)
 * [9 years ago](https://wordpress.org/support/topic/develop-with-debug-turned-on/)
 * I would recommend that you develop this plugin with debugging turned on. There
   are a number of undefined variables and indexes that should be addressed. Finding
   these and correcting them is what WP’s debug mode is for. These items would throw
   PHP notices on sites that have display notices enabled, regardless of whether
   debug mode was turned on or not.
 * Here are some that I found that could be resolved easily:
 * On CPT save/update, the two checkbox options (show description and hide line 
   numbers) do not check to see if the $_POST is set before checking its value. 
   If left unchecked this results in an undefined index notice.
 * To fix this, line 548 of /includes/class-codesnips.php should be:
 * `if ( isset( $_POST["snippet_show_description"] ) && $_POST["snippet_show_description"]
   == "true" ) {`
 * and line 552 should be:
 * `if ( isset( $_POST["snippet_hide_gutter"] ) && $_POST["snippet_hide_gutter"]
   == "true" ) {`
 * On the front end, when viewing a snippet, there are also a number of undefined
   indexes depending on what was set for the snippet. This occurs in the shortcode()
   method of the class and appears to be due to checking if certain indexes are 
   true, but assuming they are set. The shortcode method should start out by using
   [shortcode_atts()](https://codex.wordpress.org/Function_Reference/shortcode_atts)
   to define default values for the possible array keys of $atts and then merging
   those with what actually comes in as an argument to the function.
 * I don’t know what those defaults would/should be without fully debugging the 
   process, but a basic starting point would be opening your shortcode() method 
   with the following:
 *     ```
       $atts = shortcode_atts( 
       	array ( 
       		'id' => '',
       		'desc' => '',
       		'meta' => '',
       		'gutter' => '',
       		'fontsize' => '',
       	), $atts );
       ```
   
 * This would establish the keys regardless of whether they are passed or not so
   that their values can be checked without also checking whether they are defined.
   shortcode_atts() will merge in any values that are passed in the $atts argument
   when the function is called.
 * I like the plugin, but these items should be addressed and fixed in a future 
   release so that possible errors are avoided on sites that may have PHP notices
   enabled.

Viewing 1 replies (of 1 total)

 *  Plugin Author [Pat O’Brien](https://wordpress.org/support/users/obrienlabs/)
 * (@obrienlabs)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/develop-with-debug-turned-on/#post-9603178)
 * Thanks Chad. Sorry for the delay on replying to this. I never get notifications
   for “support” requests here.
 * Anyways, as you can tell it’s been a while since there’s been an update. I’ll
   look into cleaning this up. This plugin was one of my firsts a few years ago –
   I’ve learned a lot since then so I’m sure it’s due for a bit of clean up.
 * I’m also upgrading to the latest version of Ace Editor in the next version.

Viewing 1 replies (of 1 total)

The topic ‘Develop with Debug Turned On’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/codesnips_5f5f5f.svg)
 * [codeSnips](https://wordpress.org/plugins/codesnips/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/codesnips/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/codesnips/)
 * [Active Topics](https://wordpress.org/support/plugin/codesnips/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/codesnips/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/codesnips/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Pat O’Brien](https://wordpress.org/support/users/obrienlabs/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/develop-with-debug-turned-on/#post-9603178)
 * Status: resolved