Skip to content

Deprecate wplf_{$form->ID}_* and wplf_{$forms->post_name}_* actions and filters #169

@k1sul1

Description

@k1sul1

While it was a good idea at the time (#52), it's cumbersome to add new filters and actions. I think I implemented it the way I did, because I heavily dislike this, probably because I've been bitten by it more times than I can count:

add_action(
  'x', 
  function($x, $y, $z) {

  },
  10,
  3
);

I've no clue why WordPress chose to add the $accepted_args parameter, when they could've just passed all available arguments to the function like a normal person, but what is done is done and that ain't changing anytime soon. Probably some prehistoric reasons that I don't know of. I looked at call_user_func and call_user_func_array, and there's zero indication of having to know the amount of parameters.

Nevertheless, I propose that we start doing this instead of creating 3 filters / actions every time we add a new one.

$data = do_action('wplf_form_something', $data, $form); 

I don't know if we have access to full $form post object everywhere where we have these kind of filters, if we don't, then we should just get the full post object. I don't want to do this.

$data = do_action('wplf_form_something', $data, $form->ID, $form->post_name); 

I suggest that we use _deprecated_function (or create our own equivalent, because you know...) and deprecate all filters and actions that are like this. I don't want to remove them in 2.0, but I certainly don't want any new projects using them either.

Although naming things is hard, it should be pretty easy to create equivalent filters and actions that follow the new style. I wouldn't just do them without thought though, but instead make a list of all of our available actions and filters and figure out a consistent naming scheme for all of them.

v3.0 would remove the deprecated things completely. 3.0 doesn't have to include huge amounts of new features, it's just to indicate breaking changes. Practise what you preach, use semantic versioning and so on.

Pinging @rask @luizbills @ironland @libreform/maintainers and everyone else that might care.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions