Title: PATCH sharebar 1.2.5 fix undefined variable error
Last modified: August 20, 2016

---

# PATCH sharebar 1.2.5 fix undefined variable error

 *  [lkraav](https://wordpress.org/support/users/lkraav/)
 * (@lkraav)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/patch-sharebar-125-fix-undefined-variable-error/)
 * Your current sharebar_auto() approach isn’t very good. The if condition can easily
   fail and then you’re accessing variables that were only set inside the if. Here’s
   a better function version:
 *     ```
       98 function sharebar_auto($content){
        99     if((get_option('sharebar_auto_posts') && is_single()) || (get_option('sharebar_auto_pages') && is_page())){
       100         $str = sharebar(false); $str .= sharebar_horizontal(false);
       101         $content = $str.$content;
       102     }
       103
       104     return $content;
       105 }
       ```
   
 * [http://wordpress.org/extend/plugins/sharebar/](http://wordpress.org/extend/plugins/sharebar/)

The topic ‘PATCH sharebar 1.2.5 fix undefined variable error’ is closed to new replies.

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

 * 0 replies
 * 1 participant
 * Last reply from: [lkraav](https://wordpress.org/support/users/lkraav/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/patch-sharebar-125-fix-undefined-variable-error/)
 * Status: not resolved