Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Allow customize_loaded_components filter to remove posts component #132

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

Comments

@westonruter
Copy link
Contributor

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 pushed a commit that referenced this issue Aug 17, 2016
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
Copy link
Contributor

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 pushed a commit that referenced this issue Aug 17, 2016
$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 pushed a commit that referenced this issue Aug 17, 2016
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.
westonruter added a commit that referenced this issue Aug 17, 2016
Issue #132 : Allow filtering to disable 'posts' component.
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

3 participants