simpliko / wpadverts

WordPress Classifieds Plugin
https://wpadverts.com/
GNU General Public License v2.0
20 stars 11 forks source link

BUG: Invalid argument supplied for foreach()... #144

Closed erikdemarco closed 2 years ago

erikdemarco commented 2 years ago

If you see this line: =>https://github.com/simpliko/wpadverts/blob/43025dc7cf26ab77db21978595e29c055eee6c88/includes/class-form.php#L164

It needs 'params'. And if you see this example code here: => https://wpadverts.com/doc/forms-api/

adverts_form_add_validator("in_between", array(
    "callback" => "in_between",
    "label" => "In Between",
    "default_error" => __( "Incorrect value.", "adverts" ),
    "message" => array(
        "to_small" => "Value has to be greater than %min%.",
        "to_big" => "Value has to be smaller than %max%."
    ),
    "validate_empty" => false
));

There is no 'params' supplied, thus giving error.

gwin commented 2 years ago

I will check this in the next release thanks.

In the meantime, it seems the solution would be to always have the "params" argument in the array like this

adverts_form_add_validator("in_between", array(
    "callback" => "in_between",
    "label" => "In Between",
    "default_error" => __( "Incorrect value.", "adverts" ),
    "message" => array(
        "to_small" => "Value has to be greater than %min%.",
        "to_big" => "Value has to be smaller than %max%."
    ),
    "validate_empty" => false,
    "params" => array()
));