WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#2939 closed defect (bug) (wontfix)

Variables set in header.php, footer.php, sidebar.php are not inherited by the rest of the page

Reported by: technosailor Owned by: anonymous
Priority: normal Milestone:
Component: Template Version: 2.0.4
Severity: minor Keywords: has-patch
Cc: reuben-dev@…

Description

I'm not quite sure how to tackle patching this as variables are arbitrary, but when get_header(), get_footer() and get_sidebar() are called, variables won't be passed for use in the main page template.

Call it an annoyance. Not sure how to proceed with passing variables back without returning them in the function or globalizing them. Alternate workarounds are to include() the templates, but this defeats the "purdiness" of the WP functions.

Any thoughts on how to correct?

Attachments (2)

patch-2939a.diff (940 bytes) - added by nelsonrp 7 years ago.
patch for wp-includes/theme.php to import/export global name-space
global-speed.php (1.7 KB) - added by nelsonrp 7 years ago.
Speed test script.

Download all attachments as: .zip

Change History (8)

comment:1 ryan7 years ago

  • Milestone changed from 2.0.4 to 2.1

I suppose globalizing is probably simplest.

nelsonrp7 years ago

patch for wp-includes/theme.php to import/export global name-space

comment:2 nelsonrp7 years ago

  • Keywords has-patch added

comment:3 markjaquith7 years ago

Are there any performance issues with this?

nelsonrp7 years ago

Speed test script.

comment:4 nelsonrp7 years ago

  • Cc reuben-dev@… added

It's only called twice per page load, so I expect the impact is minimal. I created a test script for 100 globals and 100 locals called twice (the second call will see 200 globals). On my PowerBook G4 1.5 GHz machine it takes 0.03-0.04 seconds. I'm not sure if this is acceptable or not. Perhaps making it optional? Notice how in the test script (attached as "global-speed.php") I wrap a conditional around the global import/export code.

comment:5 matt7 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

It's better for individual vars to set them, rather than us doing it automatically.

comment:6 Nazgul6 years ago

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