This repository was archived by the owner on Dec 16, 2022. It is now read-only.
Issue #132 : Allow filtering to disable 'posts' component.#219
Merged
westonruter merged 5 commits intodevelopfrom Aug 17, 2016
Merged
Issue #132 : Allow filtering to disable 'posts' component.#219westonruter merged 5 commits intodevelopfrom
westonruter merged 5 commits intodevelopfrom
Conversation
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.
Contributor
|
@kienstra this is looking good. Regarding the fatal error, the fix should be simple. At the top of if ( ! isset( $wp_customize->posts ) ) {
return;
}That should do it. We just have to account for the same situation as another plugin that looks for whether the posts component is enabled. |
added 2 commits
August 17, 2016 03:12
$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.
WP_Customize_Posts may not be instantiated if a filter removes 'posts'. So the class WP_Customize_Postmeta_Setting may not exist. In this case, it would cause a fatal error, when accessing its property. So begin the conditional with class_exists().
Author
|
Hi @westonruter, |
| */ | ||
| function filter_customize_loaded_components( $components, $wp_customize ) { | ||
| require_once dirname( __FILE__ ) . '/class-wp-customize-posts.php'; | ||
| $wp_customize->posts = new WP_Customize_Posts( $wp_customize ); |
Contributor
There was a problem hiding this comment.
Add a third true argument to in_array() for strict checking.
added 2 commits
August 17, 2016 13:14
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.
Author
|
Thanks For Review Hi @westonruter, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@westonruter,
Could you please review this pull request for Issue #132?
The new filter
add_posts_to_customize_loaded_componentsadds'posts'to the array of components in the Customizer.And
WP_Customize_Postsis only instantiated if'posts'is still present.So a later filter may remove
'posts', to disable it.One issue I noticed is that if a filter does remove
'posts', it causes a fatal error:Notice: Undefined property: WP_Customize_Manager::$posts in /srv/www/wordpress-develop/src/wp-content/plugins/wp-customize-posts/php/class-customize-posts-plugin.php on line 179 Fatal error: Call to a member function add_support() on a non-object in /srv/www/wordpress-develop/src/wp-content/plugins/wp-customize-posts/php/class-customize-posts-plugin.php on line 179Removing the action on line #71 removed that error, but there was another fatal error.
I could have missed something here.
Fixes #132.