Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing "$achievement_id" and "$user_id" arguments in "badgeos_submission_form_language" filter #716

Open
ckaklamanos opened this issue Feb 2, 2020 · 4 comments

Comments

@ckaklamanos
Copy link

ckaklamanos commented Feb 2, 2020

In our implementation of BadgeOS, we need to customize the language strings of submission forms, depending on the achievement context.

For example, if our submission is about submitting a "project", we want the submission button value to be "Send project". Or, another example, if our submission is about submitting a specific "thing", we want the submission button value to be "Send your thing".

In order to achieve the above, I propose a simple enhancement that adds the passes $achievement_id and $user_id as arguments to the corresponding filter.

This filter is located here:

$defaults = apply_filters( 'badgeos_submission_form_language', $defaults );

I propose replacing:

$defaults = apply_filters( 'badgeos_submission_form_language', $defaults );
With:

$defaults = apply_filters( 'badgeos_submission_form_language', $defaults , $achievement_id , $user_id );

I will create a pull request very soon.

@ckaklamanos ckaklamanos changed the title Missing arguments in "badgeos_submission_form_language" filter Missing "$achivement_id" and "$user_id" arguments in "badgeos_submission_form_language" filter Feb 2, 2020
@ckaklamanos ckaklamanos changed the title Missing "$achivement_id" and "$user_id" arguments in "badgeos_submission_form_language" filter Missing "$achievement_id" and "$user_id" arguments in "badgeos_submission_form_language" filter Feb 2, 2020
@ckaklamanos
Copy link
Author

Here is the Pull Request for the above enhancement.

#717

@the-wooninjas
Copy link
Collaborator

Hi @ckaklamanos

We will surely update the mentioned filter in our next update.

@ckaklamanos
Copy link
Author

Hello @the-wooninjas

Thanks for letting me know.

@ckaklamanos
Copy link
Author

Hello.

I have seen that you added the above arguments in the recent plugin updates.

However, it seems that they have been added to the wrong position and still, those arguments cannot be "caught" by the filter.

Here is what I mean:

In the new plugin called "badgeos-nomination-submission-add-on" (https://wordpress.org/plugins/badgeos-nomination-submission-add-on/), in the following position:

File: badgeos-nomination-submission-add-on/includes/submission-actions.php
Line: 1750

You have added the following code:

// Patch in our achievement and user IDs
$defaults['achievement_id'] = isset( $args["achievement_id"] ) ? absint( $args["achievement_id"] ) : "";
$defaults['user_id']        = $user_ID;

The problem is that the above code comes after the "badgeos_submission_form_language" filter, therefore it is useless.

In order for the above code to be functional, it should be moved before the Line 1747, in other words before:

// Available filter for changing the language
$defaults = apply_filters( 'badgeos_submission_form_language', $defaults );

In this way, we will be able to make use of the new filter arguments.

Please let me know if the above is clear.

Is there a Github repository for this new plugin in order to create a Pull Request?

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants