Title: HTML codes are breaking Maxbutton URLs
Last modified: February 23, 2023

---

# HTML codes are breaking Maxbutton URLs

 *  Resolved [rocketpig3](https://wordpress.org/support/users/rocketpig3/)
 * (@rocketpig3)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/html-codes-are-breaking-maxbutton-urls/)
 * Please see previous thread on this topic: [https://wordpress.org/support/topic/maxbuttons-appears-to-be-altering-a-url-with-symbols-such-as/](https://wordpress.org/support/topic/maxbuttons-appears-to-be-altering-a-url-with-symbols-such-as/)
 * Previously we were able to get around this issue by changing the URL but this
   time we cannot. Changing the URL to use actual values (/ rather than %2F for 
   example) breaks the URL on the site we are linking to.
 * Placing a raw URL in WordPress does not update the codes to their actual values,
   meaning the link works, but Maxbuttons make the conversion for some reason. Is
   there any way we can prevent this?
 * Thanks

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Bas Schuiling](https://wordpress.org/support/users/basszje/)
 * (@basszje)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/html-codes-are-breaking-maxbutton-urls/#post-16500994)
 * I’ve been searching, but the call doing this is already for quite some years 
   inside of Maxbuttons. The reason was that certain URL’s could break something,
   but I’m not entirely sure.
 * Anyhow to get around it, perhaps you could use a snippet based on these filters:
 *     ```wp-block-code
       $url = apply_filters('mb-url', $url, $data['url']);  // passes processed url / raw url.
       $url = apply_filters('mb-url-' . $button_id, $url, $data['url']);
       ```
   
 *  The first parameter is the one that is processed, the second one should be raw
   what is stored. You can use it like this:
 *     ```wp-block-code
       add_filter('mb-url', function ($url, $dataUrl) 
       { 
       return $dataUrl; 
       }
       ```
   
 * Or do some checks on your own. This is a rough example. The other hook you can
   target specific buttons instead of all ( use like mb-url-x )
 *  Thread Starter [rocketpig3](https://wordpress.org/support/users/rocketpig3/)
 * (@rocketpig3)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/html-codes-are-breaking-maxbutton-urls/#post-16502004)
 * Thanks. Sorry I’m a bit inexperienced with filters, in this example is what it’s
   doing basically looking for any instances of ‘url’ in any MaxButton and replacing
   them with $dataUrl, which should be the unprocessed version?
 * Thanks
 *  Plugin Author [Bas Schuiling](https://wordpress.org/support/users/basszje/)
 * (@basszje)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/html-codes-are-breaking-maxbutton-urls/#post-16545375)
 * Hi,
 * Correct. The dataUrl is what is stored in the database without checks on the 
   URL .
 * You can use a plugin for snippets ( there are a few like ‘code snippets’ ) where
   you can experiment.
 *  Thread Starter [rocketpig3](https://wordpress.org/support/users/rocketpig3/)
 * (@rocketpig3)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/html-codes-are-breaking-maxbutton-urls/#post-16629922)
 * Hi,
 * We tried this in functions.php:
 *     ```wp-block-code
       /* URL > data URL MaxButtons */
       $url = apply_filters('mb-url', $url, $data['url']);  // passes processed url / raw url.
       $url = apply_filters('mb-url-' . $button_id, $url, $data['url']);
   
       add_filter('mb-url', function ($url, $dataUrl) 
       { 
       return $dataUrl; 
       } );
       ```
   
 * We get the error: _Uncaught ArgumentCountError: Too few arguments to function{
   closure}(), 1 passed in wp-includes/class-wp-hook.php on line 310 and exactly
   2 expected in wp-content/themes/generatepress-child/functions.php:33_
 * Line 33 is the add_filter line. I assume we have closed the filter incorrectly
   or something of that nature.
 * Thanks
 *  Plugin Author [Bas Schuiling](https://wordpress.org/support/users/basszje/)
 * (@basszje)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/html-codes-are-breaking-maxbutton-urls/#post-16630026)
 * Hi,
 * The fourth parameter of [add_filter](https://developer.wordpress.org/reference/functions/add_filter/)
   defines how much variables are being passed. Your functions demands 2 parameters,
   but by default it only passes one.
 * You should define it like this: add_filter(‘hook’, ‘<function>’, 10, 2); and 
   then it should work
 *  Plugin Author [Bas Schuiling](https://wordpress.org/support/users/basszje/)
 * (@basszje)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/html-codes-are-breaking-maxbutton-urls/#post-16678210)
 * I didn’t hear anything back, so I’m assuming the issue has been solved and the
   ticket can be closed!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘HTML codes are breaking Maxbutton URLs’ is closed to new replies.

 * ![](https://ps.w.org/maxbuttons/assets/icon-128x128.png?rev=1378636)
 * [MaxButtons - Create buttons](https://wordpress.org/plugins/maxbuttons/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/maxbuttons/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/maxbuttons/)
 * [Active Topics](https://wordpress.org/support/plugin/maxbuttons/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/maxbuttons/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/maxbuttons/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Bas Schuiling](https://wordpress.org/support/users/basszje/)
 * Last activity: [3 years, 3 months ago](https://wordpress.org/support/topic/html-codes-are-breaking-maxbutton-urls/#post-16678210)
 * Status: resolved