Title: Bug with having multiple custom html ids
Last modified: August 21, 2016

---

# Bug with having multiple custom html ids

 *  [mikemn84](https://wordpress.org/support/users/mikemn84/)
 * (@mikemn84)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/bug-with-having-multiple-custom-html-ids/)
 * Hello,
 * I believe I’ve found a bug in how the custom html ids are handled. Multiple entries
   are required to be split by a newline character. However when the plugin saves
   the html ids to the self::$fixed_widgets array, the newline character is not 
   being removed from each entry.
 * This leads to the javascript breaking because that newline character gets printed
   as javascript. So no widgets on the page will be sticky. It has few other side
   effects as well, such as not adding the widget id to the correct sidebar.
 * Anyway, I’ve fixed the problem on my machine by doing a little extra value handling
   in the check_custom_ids() function in q2w3-fixed-widget.php.
 * Change around line 81
 *     ```
       foreach ( $ids as $id ) self::$fixed_widgets[self::get_widget_sidebar($id)][$id] = "'". $id ."'";
       ```
   
 *     ```
       foreach ( $ids as $id ) {
       				$id = preg_replace("@[^a-z0-9_'-]@i", "", $id);
       				self::$fixed_widgets[self::get_widget_sidebar($id)][$id] = "'". $id ."'";
       }
       ```
   
 * [http://wordpress.org/extend/plugins/q2w3-fixed-widget/](http://wordpress.org/extend/plugins/q2w3-fixed-widget/)

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [Max Bond](https://wordpress.org/support/users/max-bond/)
 * (@max-bond)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/bug-with-having-multiple-custom-html-ids/#post-3929936)
 * Yes, you are right!
    This bug will be fixed in the next release!
 * Use trim() instead preg_replace() to remove newline characters:
 *     ```
       foreach ( $ids as $id ) {
       	$id = trim($id);
       	if ( $id ) self::$fixed_widgets[self::get_widget_sidebar($id)][$id] = "'". $id ."'";
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Bug with having multiple custom html ids’ is closed to new replies.

 * ![](https://ps.w.org/q2w3-fixed-widget/assets/icon-256x256.png?rev=2384479)
 * [Fixed Widget and Sticky Elements for WordPress](https://wordpress.org/plugins/q2w3-fixed-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/q2w3-fixed-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/q2w3-fixed-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/q2w3-fixed-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/q2w3-fixed-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/q2w3-fixed-widget/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Max Bond](https://wordpress.org/support/users/max-bond/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/bug-with-having-multiple-custom-html-ids/#post-3929936)
 * Status: not resolved