Viewing 2 posts - 1 through 2 (of 2 total)
    • Author
      Posts
    • dlt101
      Guest

      I have set WP_DEBUG = true.

      When I edit any existing sc shortcode, I see the following 2 errors on the top of the page.

      Notice: Undefined index: sc_disable in …/wp-content/plugins/shortcoder/shortcoder.php on line 179

      Notice: Undefined index: sc_hide_admin in …/wp-content/plugins/shortcoder/shortcoder.php on line 180

      Then inside the form I see this error as well:

      Notice: Undefined variable: sc_name_edit in …/wp-content/plugins/shortcoder/shortcoder.php on line 234

      Looking forward to a fix!

      Anonymous
      Guest

      Hi, dlt101,

      Good day!

      You’ll get lots of those with WP_DEBUG on. It’s just a PHP notice and doesn’t affect anything. You don’t normally turn it on if you’re on a production phase, so might as well turn it to false instead.

      This I agree to be a plugin problem though but not really a bug.

      To Vaarash, this is easy to fix and you might consider this as an update to the next version. It will only occur when WP_DEBUG is enabled:

      http://codex.wordpress.org/Editing_wp-config.php#Debug

      The fix is simple this case. The warning is caused by you checking the value of an array item inside $_POST without first checking that the key exists. PHP is very picky when you give it the chance, and demands that you never access array/object properties that odn’t exist. When you want to use part of $_POST, like the sc_disable’ key that sets off the warning described above, you need to run isset() first. So instead of

      Code:


      $sc_options[$sc_name] = array(
      ‘content’ => stripslashes($_POST[‘sc_content’]),
      ‘disabled’ => intval($_POST[‘sc_disable’]),
      ‘hide_admin’ => intval($_POST[‘sc_hide_admin’])
      );

      You should check if the key exist (isset()).

      I maybe missing something, but hope this helps.

      Thanks!

    Viewing 2 posts - 1 through 2 (of 2 total)
    • The topic ‘Errors when editing shortcode’ is closed to new replies.

    Subscribe for updates

    Get updates on the WordPress plugins, tips and tricks to enhance your WordPress experience. No spam.