WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#35896 closed defect (bug) (duplicate)

login_enqueue_scripts document bug

Reported by: suifengtec Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4.2
Component: Script Loader Keywords:
Focuses: Cc:
PR Number:

Description

the example on this document page is error:
https://codex.wordpress.org/Plugin_API/Action_Reference/login_enqueue_scripts#Example
the scripts/styles enqueued by this hook is only output before

</body>

the correct method using it may be:

<?php
add_action('login_enqueue_scripts', array('login_enqueue_scripts'));

function login_enqueue_scripts(){
        printf("<link rel='stylesheet' id='%s' href='%s' type='text/css' media='all' >\n",
            'css-id',
            esc_url(plugins_url(__FILE__).'assets/css/style.css')
            );
}

Change History (2)

#1 @suifengtec
4 years ago

  • Keywords needs-docs added
<?php
<?php
add_action('login_enqueue_scripts', array('login_enqueue_scripts'));

function login_enqueue_scripts(){
        printf("<link rel='stylesheet' id='%s' href='%s' type='text/css' media='all' >\n",
            'css-id',
            esc_url(plugins_url('assets/css/style.css',__FILE__))
            );
}

#2 @ocean90
4 years ago

  • Component changed from Administration to Script Loader
  • Focuses accessibility docs removed
  • Keywords needs-docs removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Type changed from enhancement to defect (bug)

Hello @suifengtec,

the example in the codex is correct, that's how core is currently handling stylesheets on the login page. But there is a ticket to improve this behavior, see #17916.

Note: The codex is a wiki, everyone with a WordPress.org account can edit the pages.

Note: See TracTickets for help on using tickets.