Skip to content

["BUG"] Use wp_enqueue commands #86

@MaferMazu

Description

@MaferMazu

Describe the bug
Comes from the WordPress Plugin Directory.

Your plugin is not correctly including JS and/or CSS. You should be using the built-in functions for this:

When including JavaScript code you can use:
wp_register_script() and wp_enqueue_script() to add JavaScript code from a file.
wp_add_inline_script() to add inline JavaScript code to previous declared scripts.

When including CSS you can use:
wp_register_style() and wp_enqueue_style() to add CSS from a file.
wp_add_inline_style() to add inline CSS to previously declared CSS.

Note that as of WordPress 5.7, you can pass attributes like async, nonce, and type by using new functions and filters: https://make.wordpress.org/core/2021/02/23/introducing-script-attributes-related-functions-in-wordpress-5-7/

If you're trying to enqueue on the admin pages you'll want to use the admin enqueues.

https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/
https://developer.wordpress.org/reference/hooks/admin_print_scripts/
https://developer.wordpress.org/reference/hooks/admin_print_styles/

Example(s) from your plugin:

20_17-03-56_openedx-commerce1/admin/views/class-openedx-commerce-enrollment-info-form.php:230 <script>
20_17-03-56_openedx-commerce1/admin/views/class-openedx-commerce-enrollment-info-form.php:248 <style>

Metadata

Metadata

Assignees

Labels

bugReport of or fix for something that isn't working as intendedhelp wantedReady to be picked up by anyone in the community

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions