close
The Wayback Machine - https://web.archive.org/web/20200928004207/https://github.com/WordPress/two-factor/pull/356
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

Register scripts before being enqueued #356

Closed

Conversation

@cojennin
Copy link

cojennin commented May 13, 2020

Registering the fido-u2f-api and fido-u2f-login scripts in the __constructor is generating the following notice:
Notice: wp_register_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks.

It seems like these wp_register_script calls should be moved to login_enqueue_assets as that's where they're utilized.

(Props @scottnelle for tracking this down)

Copy link
Collaborator

kasparsd left a comment

This looks great, thank you!

@@ -130,6 +114,23 @@ public function get_label() {
* @since 0.1-dev
*/
public function login_enqueue_assets() {

wp_register_script(
'fido-u2f-api',

This comment has been minimized.

@kasparsd

kasparsd May 13, 2020 Collaborator

Looks like this is also referenced here:

wp_enqueue_script(
'fido-u2f-admin',
plugins_url( 'js/fido-u2f-admin.js', __FILE__ ),
array( 'jquery', 'fido-u2f-api' ),
self::asset_version(),
true
);

so we need to make sure this script is registered before it is enqueued there.

This comment has been minimized.

@cojennin

cojennin May 13, 2020 Author

Ah yea, made a change to the PR to register on admin_enqueue_scripts with a lower priority to make sure it gets registered prior to this. But when does login_enqueue_assets get called?

@cojennin cojennin force-pushed the cojennin:fix/register-scripts-fido-u2f branch from 7f2f616 to de6d035 May 13, 2020
@kasparsd kasparsd self-requested a review May 13, 2020
@rinatkhaziev
Copy link

rinatkhaziev commented Jun 17, 2020

Hi @kasparsd ,

Any plans to get this merged in the next release?

@kasparsd
Copy link
Collaborator

kasparsd commented Jun 26, 2020

Fixes #361.

@kasparsd
Copy link
Collaborator

kasparsd commented Jun 26, 2020

There appear to be a few code style issues reported here https://travis-ci.com/github/WordPress/two-factor/jobs/333298974 and a merge conflict with the latest changes introduced by the latest worked merged into master.

Is it OK if I open a new pull request to fix these and also make sure the scripts are available on the login screen?

@kasparsd
Copy link
Collaborator

kasparsd commented Jun 26, 2020

Replacing this with #368 if that's OK.

@rinatkhaziev, @cojennin Could you please code review #368?

@kasparsd kasparsd closed this Jun 26, 2020
@kasparsd kasparsd mentioned this pull request Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.