Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Bas Schuiling

    (@basszje)

    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:

    $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:

    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

    (@rocketpig3)

    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

    (@basszje)

    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

    (@rocketpig3)

    Hi,

    We tried this in functions.php:

    
    /* 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

    (@basszje)

    Hi,

    The fourth parameter of 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

    (@basszje)

    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.