Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#40225 closed defect (bug) (invalid)

Using wp_enqueue_style() with 'admin_enqueue_scripts' results in unresponsive "Screen Options" button

Reported by: shastjion's profile shastjion Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7.3
Component: Script Loader Keywords:
Focuses: ui, javascript Cc:

Description

Attempting to enqueue a .css file to style admin area elements using the following results in a unresponsive "screen options" button:

function load_admin_style() {
  wp_enqueue_style('admin_css', get_template_directory_uri() . '/library/css/style.css');
}
add_action( 'admin_enqueue_scripts', 'load_admin_style' );

The .css is present and loaded correctly however.

---

Using wp_enqueue_script() results in both the .css file and the other js being loaded correctly:

function load_admin_style() {
  wp_enqueue_script('admin_css', get_template_directory_uri() . '/library/css/style.css');
}
add_action( 'admin_enqueue_scripts', 'load_admin_style' );

Change History (3)

#1 @SergeyBiryukov
8 years ago

  • Component changed from General to Script Loader
  • Focuses accessibility removed
  • Keywords reporter-feedback added

Hi @shastjion, welcome to WordPress Trac! Thanks for the report.

wp_enqueue_style() by itself should not cause any issues with "Screen Options" button, so I think there might be a CSS or JS conflict with the particular styles you're using.

  • Could you share the contents of library/css/style.css file?
  • Does it still happen on a clean install with all plugins disabled and a default theme (Twenty Seventeen) activated?

Using wp_enqueue_script() results in both the .css file and the other js being loaded correctly:

function load_admin_style() {
  wp_enqueue_script('admin_css', get_template_directory_uri() . '/library/css/style.css');
}
add_action( 'admin_enqueue_scripts', 'load_admin_style' );

Note that the usage of wp_enqueue_script() is invalid here, as you're loading a CSS file in a <script> tag.

#2 @shastjion
8 years ago

  • Keywords reporter-feedback removed
  • Resolution set to invalid
  • Status changed from new to closed

Hi @SergeyBiryukov,

My apologies, it was indeed the .css file, swapping it with an empty .css file resolved the issue.
I'll need to do some debugging now. Sorry for having wasted your time.

#3 @ocean90
8 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.