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

Commit a82ea99

Browse files
committed
Prevent loading postmeta controllers if posts component is disabled
1 parent 986879d commit a82ea99

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

php/class-customize-posts-plugin.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ public function __construct() {
7070
add_filter( 'customize_loaded_components', array( $this, 'add_posts_to_customize_loaded_components' ), 0, 1 );
7171
add_filter( 'customize_loaded_components', array( $this, 'filter_customize_loaded_components' ), 100, 2 );
7272
add_action( 'customize_register', array( $this, 'load_support_classes' ) );
73-
74-
require_once dirname( __FILE__ ) . '/class-wp-customize-postmeta-controller.php';
75-
require_once dirname( __FILE__ ) . '/class-wp-customize-page-template-controller.php';
76-
require_once dirname( __FILE__ ) . '/class-wp-customize-featured-image-controller.php';
77-
$this->page_template_controller = new WP_Customize_Page_Template_Controller();
78-
$this->featured_image_controller = new WP_Customize_Featured_Image_Controller();
7973
}
8074

8175
/**
@@ -175,6 +169,12 @@ function filter_customize_loaded_components( $components, $wp_customize ) {
175169
require_once dirname( __FILE__ ) . '/class-wp-customize-posts.php';
176170
if ( in_array( 'posts', $components, true ) ) {
177171
$wp_customize->posts = new WP_Customize_Posts( $wp_customize );
172+
173+
require_once dirname( __FILE__ ) . '/class-wp-customize-postmeta-controller.php';
174+
require_once dirname( __FILE__ ) . '/class-wp-customize-page-template-controller.php';
175+
require_once dirname( __FILE__ ) . '/class-wp-customize-featured-image-controller.php';
176+
$this->page_template_controller = new WP_Customize_Page_Template_Controller();
177+
$this->featured_image_controller = new WP_Customize_Featured_Image_Controller();
178178
}
179179

180180
return $components;

php/class-edit-post-preview.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function can_load_customize_post_preview() {
6060
public function filter_customize_loaded_component( $components ) {
6161
if ( $this->can_load_customize_post_preview() ) {
6262
foreach ( array( 'widgets', 'nav_menus' ) as $component ) {
63-
$i = array_search( $component, $components );
63+
$i = array_search( $component, $components, true );
6464
if ( false !== $i ) {
6565
unset( $components[ $i ] );
6666
}

0 commit comments

Comments
 (0)