WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#15782 new enhancement

Consolidate header Javascript

Reported by: dd32 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.1
Component: Administration Keywords: has-patch needs-testing
Focuses: Cc:

Description

As a followon to #15781

Currently there is a block of Javascript required on all admin pages, this is stored directly within admin-header.php, and iframe_header(). Unfortunately, when someone changes/adds code to one, the other is not always updated.

This inline Javascript should be moved to a function and printed on a header action in order to reduce code duplication and prevent future issues.

Attachments (2)

garyc40-15782.patch (9.2 KB) - added by garyc40 3 years ago.
there's a patch for that
15782.2.diff (8.4 KB) - added by garyc40 3 years ago.
remove redundant admin_script_globals() function

Download all attachments as: .zip

Change History (8)

comment:1 ocean903 years ago

Also wp_iframe().

comment:2 duck_3 years ago

And wp-admin/press-this.php

garyc403 years ago

there's a patch for that

comment:3 garyc403 years ago

  • Keywords has-patch needs-testing added

comment:4 nacin3 years ago

Re: press-this.php, see also the wp_tiny_mce and wp_tiny_mce_preload_dialogs calls.

Edit: reference, #15561.

Last edited 3 years ago by nacin (previous) (diff)

garyc403 years ago

remove redundant admin_script_globals() function

comment:5 scribu3 years ago

  • Keywords 3.2-early removed
  • Summary changed from Consolodate header Javascript to Consolidate header Javascript

comment:6 azaozz3 years ago

At first look the patch seems right, it removes few duplicate lines of HTML and replaces them with two PHP functions. However at closer look it actually adds more code instead of reducing it.

It also seems to loose the $hook_suffix global which seems to be redundant in the first place as only the $admin_body_class global is needed in the script. Another weakness is that the patch allows defaults to be overwritten. These JS globals should be consistent and exactly the same as the PHP globals.

Perhaps a better approach is to just output the script as it is in the admin head at the moment, without much PHP processing.

Note: See TracTickets for help on using tickets.