-
Notifications
You must be signed in to change notification settings - Fork 368
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
Repair edit job listing screen. #2802
Conversation
@@ -136,7 +136,7 @@ public function process() { | |||
* @param array $atts Attributes to use in the view handler. | |||
*/ | |||
public function output( $atts = [] ) { | |||
WP_Job_Manager\WP_Job_Manager_Recaptcha::enqueue_scripts(); | |||
WP_Job_Manager\WP_Job_Manager_Recaptcha::enqueue_recaptcha(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't tested yet, but it looks fragile to add the hooks that process submit fields in the output and enqueue functions. Those might not get called or get called later than process()
. Does it only work now because the submit job form has multiple steps?
Since reCAPTCHA is only used on specific forms I think the abstract WP_Job_Manager_Form
class, which has the common code for every form, isn't the place to set it up. Looks like there are separate WP_Job_Manager_Form_Edit_Job
and WP_Job_Manager_Form_Submit_Job
classes, should the hooks be added from here?:
WP_Job_Manager\WP_Job_Manager_Recaptcha::instance(); |
(Unfortunately WP_Job_Manager_Form_Edit_Job
extends WP_Job_Manager_Form_Submit_Job
so we still need something to not load it for editing. Maybe a ...Submit_Job::init_recaptcha()
method that the ...Edit_Job
class overrides?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point, I also thought about this initially but I ended up taking the quick approach since it worked. I'll look into refactoring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so I moved everything inside the recaptcha class. I also did some fixes regarding versioning as it seems that previously the latest version of the paid plugins didn't work with old WPJM versions. I have updated the testing instructions to reflect that.
Previously the hooks where added on instance creation which would cause the hooks to be added on the job edit form and break it.
a57dfc1
to
456d26b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Co-authored-by: Peter Kiss <[email protected]>
Co-authored-by: Peter Kiss <[email protected]>
Oveview
This fixes an issue to the edit job listing screen. To reproduce:
The problem was that we added the actions to the
WP_Job_Manager_Recaptcha
constructor. This way the hooks were added even when we wanted to call utility methods and the captcha was also enqueued to the dashboard page.Changes Proposed in this Pull Request
equeue_scripts
. This way we only enqueue the captcha when we need to.Testing Instructions