Skip to content

Commit 8a1f39e

Browse files
committed
Add is_customize_preview() polyfill
1 parent 3d15e51 commit 8a1f39e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

features/extra/polyfills.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,30 @@ function get_theme_file_uri( $file = '' ) {
5252
return apply_filters( 'theme_file_uri', $url, $file );
5353
}
5454
}
55+
56+
/*
57+
* Add a polyfill for the is_customize_preview(), as it is required for the
58+
* TwentyTwenty theme's starter content, and will fatal the site if you install
59+
* WP 5.3 first (setting TwentyTwenty as the active theme) and then downgrade
60+
* to a version of WP lower than 4.0.
61+
*
62+
* Note: This is a quick fix, and a cleaner solution would be to change the
63+
* active theme on downgrading, if the current theme declares it is not
64+
* supported.
65+
*
66+
* See: https://github.com/WordPress/twentytwenty/issues/973
67+
*/
68+
if ( ! function_exists( 'is_customize_preview' ) ) {
69+
/**
70+
* Whether the site is being previewed in the Customizer.
71+
*
72+
* @since 4.0.0
73+
*
74+
* @global WP_Customize_Manager $wp_customize Customizer instance.
75+
*
76+
* @return bool True if the site is being previewed in the Customizer, false otherwise.
77+
*/
78+
function is_customize_preview() {
79+
return false;
80+
}
81+
}

0 commit comments

Comments
 (0)