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

Commit

Permalink
Prevent loading postmeta controllers if posts component is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Sep 11, 2016
1 parent 986879d commit a82ea99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions php/class-customize-posts-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ public function __construct() {
add_filter( 'customize_loaded_components', array( $this, 'add_posts_to_customize_loaded_components' ), 0, 1 );
add_filter( 'customize_loaded_components', array( $this, 'filter_customize_loaded_components' ), 100, 2 );
add_action( 'customize_register', array( $this, 'load_support_classes' ) );

require_once dirname( __FILE__ ) . '/class-wp-customize-postmeta-controller.php';
require_once dirname( __FILE__ ) . '/class-wp-customize-page-template-controller.php';
require_once dirname( __FILE__ ) . '/class-wp-customize-featured-image-controller.php';
$this->page_template_controller = new WP_Customize_Page_Template_Controller();
$this->featured_image_controller = new WP_Customize_Featured_Image_Controller();
}

/**
Expand Down Expand Up @@ -175,6 +169,12 @@ function filter_customize_loaded_components( $components, $wp_customize ) {
require_once dirname( __FILE__ ) . '/class-wp-customize-posts.php';
if ( in_array( 'posts', $components, true ) ) {
$wp_customize->posts = new WP_Customize_Posts( $wp_customize );

require_once dirname( __FILE__ ) . '/class-wp-customize-postmeta-controller.php';
require_once dirname( __FILE__ ) . '/class-wp-customize-page-template-controller.php';
require_once dirname( __FILE__ ) . '/class-wp-customize-featured-image-controller.php';
$this->page_template_controller = new WP_Customize_Page_Template_Controller();
$this->featured_image_controller = new WP_Customize_Featured_Image_Controller();
}

return $components;
Expand Down
2 changes: 1 addition & 1 deletion php/class-edit-post-preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function can_load_customize_post_preview() {
public function filter_customize_loaded_component( $components ) {
if ( $this->can_load_customize_post_preview() ) {
foreach ( array( 'widgets', 'nav_menus' ) as $component ) {
$i = array_search( $component, $components );
$i = array_search( $component, $components, true );
if ( false !== $i ) {
unset( $components[ $i ] );
}
Expand Down

0 comments on commit a82ea99

Please sign in to comment.