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

Allow customize_loaded_components filter to remove posts component #132

Closed
westonruter opened this issue May 5, 2016 · 1 comment

Comments

Projects
None yet
3 participants
@westonruter
Copy link
Contributor

commented May 5, 2016

Currently there is one customize_loaded_components filter which handles the injection of the WP_Customize_Posts instance into WP_Customize_Manager:

add_filter( 'customize_loaded_components', array( $this, 'filter_customize_loaded_components' ), 100, 2 );

There should be another customize_loaded_components filter that runs earlier at priority 0 which amends posts to the list of components. Then the later filter can check to see of posts is in the array and then only instantiate WP_Customize_Posts if it is present.

This would allow plugins to use a more standard way to selectively disable the posts component.

@westonruter westonruter modified the milestone: 0.8 Aug 6, 2016

@kienstra kienstra self-assigned this Aug 17, 2016

kienstra added a commit that referenced this issue Aug 17, 2016

Issue #132 : Allow filtering to disable 'posts' component.
A new filter adds 'posts' to the array of components in the Customizer.
WP_Customize_Posts is only instantiated if 'posts' is still present.
So a filter may remove 'posts', to disable it.
@kienstra

This comment has been minimized.

Copy link
Contributor

commented Aug 17, 2016

Pull Request

@westonruter,
Could you please review this pull request when you have a chance? It sets a new filter add_posts_to_customize_loaded_components. This adds 'posts' to the array of components in the Customizer. And WP_Customize_Posts is only instantiated if 'posts' is still present. So a later filter may remove 'posts', to disable it.

kienstra added a commit that referenced this issue Aug 17, 2016

Issue #132 : Prevent error from using an undefined property.
$wp_customize->posts is now only set if 'posts' isn't removed with a filter.
And before, removing it caused an error.
So if #wp_customize->posts is not set, return from load_support_classes.

kienstra added a commit that referenced this issue Aug 17, 2016

Issue #132 : Apply Weston's feedback - arguments and strict checking.
Remove $wp_customize param  and its DocBlock line--it's not used.
And reduce argument count in add_filter to 1.
Also, add 3rd argument true to in_array for strict evaluation.

kienstra added a commit that referenced this issue Aug 17, 2016

westonruter added a commit that referenced this issue Aug 17, 2016

Merge pull request #219 from xwp/feature/allow-removing-posts-component
Issue #132 : Allow filtering to disable 'posts' component.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.