Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store display_sidebar in static variable #1196

Merged
merged 1 commit into from
Nov 12, 2014
Merged

Store display_sidebar in static variable #1196

merged 1 commit into from
Nov 12, 2014

Conversation

QWp6t
Copy link
Member

@QWp6t QWp6t commented Nov 5, 2014

This is for users who might call this function more than once for whatever reason. It ensures that each return from the function is always the same value (so if you hook into the filter, do it before an initial call to roots_display_sidebar()).

In addition to that practical benefit, this is also more performant in that each call to the function will no longer create a new Roots_Sidebar object, nor will each call to the function run the callbacks for 'roots/display_sidebar'; these will only be done on the initial call to the function to populate the value of the static variable.


return apply_filters('roots/display_sidebar', $sidebar_config->display);
if(!isset($display)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space after if to match the rest of the codebase

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops. fixed. ;o

@QWp6t
Copy link
Member Author

QWp6t commented Nov 11, 2014

Rebased.

retlehs added a commit that referenced this pull request Nov 12, 2014
Store display_sidebar in static variable
@retlehs retlehs merged commit 554e3e7 into roots:master Nov 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants