Make WordPress Core

Opened 5 years ago

Last modified 14 months 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-refresh
Focuses: Cc:


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 5 years ago.
there's a patch for that
15782.2.diff (8.4 KB) - added by garyc40 5 years ago.
remove redundant admin_script_globals() function

Download all attachments as: .zip

Change History (9)

comment:1 @ocean905 years ago

Also wp_iframe().

comment:2 @duck_5 years ago

And wp-admin/press-this.php

@garyc405 years ago

there's a patch for that

comment:3 @garyc405 years ago

  • Keywords has-patch needs-testing added

comment:4 @nacin5 years ago

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

Version 0, edited 5 years ago by nacin (next)

@garyc405 years ago

remove redundant admin_script_globals() function

comment:5 @scribu4 years ago

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

comment:6 @azaozz4 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.

comment:7 @wonderboymusic14 months ago

  • Keywords needs-refresh added; needs-testing removed
Note: See TracTickets for help on using tickets.