summaryrefslogtreecommitdiffstats
path: root/wp-includes/theme.php
diff options
context:
space:
mode:
Diffstat (limited to 'wp-includes/theme.php')
-rw-r--r--wp-includes/theme.php59
1 files changed, 46 insertions, 13 deletions
diff --git a/wp-includes/theme.php b/wp-includes/theme.php
index 7157318..6dbb4cf 100644
--- a/wp-includes/theme.php
+++ b/wp-includes/theme.php
@@ -91,7 +91,7 @@ function wp_get_themes( $args = array() ) {
if ( null !== $args['errors'] ) {
foreach ( $themes as $theme => $wp_theme ) {
- if ( $wp_theme->errors() != $args['errors'] ) {
+ if ( (bool) $wp_theme->errors() !== $args['errors'] ) {
unset( $themes[ $theme ] );
}
}
@@ -514,7 +514,7 @@ function search_theme_directories( $force = false ) {
// Start with directories in the root of the active theme directory.
$dirs = @ scandir( $theme_root );
if ( ! $dirs ) {
- trigger_error( "$theme_root is not readable", E_USER_NOTICE );
+ wp_trigger_error( __FUNCTION__, "$theme_root is not readable" );
continue;
}
foreach ( $dirs as $dir ) {
@@ -538,7 +538,7 @@ function search_theme_directories( $force = false ) {
*/
$sub_dirs = @ scandir( $theme_root . '/' . $dir );
if ( ! $sub_dirs ) {
- trigger_error( "$theme_root/$dir is not readable", E_USER_NOTICE );
+ wp_trigger_error( __FUNCTION__, "$theme_root/$dir is not readable" );
continue;
}
foreach ( $sub_dirs as $sub_dir ) {
@@ -577,7 +577,7 @@ function search_theme_directories( $force = false ) {
$theme_roots[ $theme_dir ] = $relative_theme_roots[ $theme_data['theme_root'] ]; // Convert absolute to relative.
}
- if ( get_site_transient( 'theme_roots' ) != $theme_roots ) {
+ if ( get_site_transient( 'theme_roots' ) !== $theme_roots ) {
set_site_transient( 'theme_roots', $theme_roots, $cache_expiration );
}
@@ -705,9 +705,9 @@ function get_raw_theme_root( $stylesheet_or_template, $skip_cache = false ) {
// If requesting the root for the active theme, consult options to avoid calling get_theme_roots().
if ( ! $skip_cache ) {
- if ( get_option( 'stylesheet' ) == $stylesheet_or_template ) {
+ if ( get_option( 'stylesheet' ) === $stylesheet_or_template ) {
$theme_root = get_option( 'stylesheet_root' );
- } elseif ( get_option( 'template' ) == $stylesheet_or_template ) {
+ } elseif ( get_option( 'template' ) === $stylesheet_or_template ) {
$theme_root = get_option( 'template_root' );
}
}
@@ -942,7 +942,7 @@ function validate_current_theme() {
* if it turns out there is no default theme installed. (That's `false`.)
*/
$default = WP_Theme::get_core_default_theme();
- if ( false === $default || get_stylesheet() == $default->get_stylesheet() ) {
+ if ( false === $default || get_stylesheet() === $default->get_stylesheet() ) {
return true;
}
@@ -1567,7 +1567,7 @@ function get_custom_header() {
if ( ! empty( $_wp_default_headers ) ) {
foreach ( (array) $_wp_default_headers as $default_header ) {
$url = vsprintf( $default_header['url'], $directory_args );
- if ( $data['url'] == $url ) {
+ if ( $data['url'] === $url ) {
$data = $default_header;
$data['url'] = $url;
$data['thumbnail_url'] = vsprintf( $data['thumbnail_url'], $directory_args );
@@ -2642,6 +2642,7 @@ function get_theme_starter_content() {
* @since 6.3.0 The `border` feature allows themes without theme.json to add border styles to blocks.
* @since 6.5.0 The `appearance-tools` feature enables a few design tools for blocks,
* see `WP_Theme_JSON::APPEARANCE_TOOLS_OPT_INS` for a complete list.
+ * @since 6.6.0 The `editor-spacing-sizes` feature was added.
*
* @global array $_wp_theme_features
*
@@ -2669,6 +2670,7 @@ function get_theme_starter_content() {
* - 'editor-color-palette'
* - 'editor-gradient-presets'
* - 'editor-font-sizes'
+ * - 'editor-spacing-sizes'
* - 'editor-styles'
* - 'featured-content'
* - 'html5'
@@ -3434,6 +3436,7 @@ function get_registered_theme_feature( $feature ) {
* @since 3.0.0
* @since 4.3.0 Also removes `header_image_data`.
* @since 4.5.0 Also removes custom logo theme mods.
+ * @since 6.6.0 Also removes `site_logo` option set by the site logo block.
*
* @param int $id The attachment ID.
*/
@@ -3441,19 +3444,24 @@ function _delete_attachment_theme_mod( $id ) {
$attachment_image = wp_get_attachment_url( $id );
$header_image = get_header_image();
$background_image = get_background_image();
- $custom_logo_id = get_theme_mod( 'custom_logo' );
+ $custom_logo_id = (int) get_theme_mod( 'custom_logo' );
+ $site_logo_id = (int) get_option( 'site_logo' );
- if ( $custom_logo_id && $custom_logo_id == $id ) {
+ if ( $custom_logo_id && $custom_logo_id === $id ) {
remove_theme_mod( 'custom_logo' );
remove_theme_mod( 'header_text' );
}
- if ( $header_image && $header_image == $attachment_image ) {
+ if ( $site_logo_id && $site_logo_id === $id ) {
+ delete_option( 'site_logo' );
+ }
+
+ if ( $header_image && $header_image === $attachment_image ) {
remove_theme_mod( 'header_image' );
remove_theme_mod( 'header_image_data' );
}
- if ( $background_image && $background_image == $attachment_image ) {
+ if ( $background_image && $background_image === $attachment_image ) {
remove_theme_mod( 'background_image' );
}
}
@@ -3562,7 +3570,7 @@ function _wp_customize_include() {
$changeset_uuid = false;
/*
- * Set initially fo false since defaults to true for back-compat;
+ * Set initially to false since defaults to true for back-compat;
* can be overridden via the customize_changeset_branching filter.
*/
$branching = false;
@@ -4221,6 +4229,31 @@ function create_initial_theme_features() {
)
);
register_theme_feature(
+ 'editor-spacing-sizes',
+ array(
+ 'type' => 'array',
+ 'description' => __( 'Custom spacing sizes if defined by the theme.' ),
+ 'show_in_rest' => array(
+ 'schema' => array(
+ 'items' => array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'name' => array(
+ 'type' => 'string',
+ ),
+ 'size' => array(
+ 'type' => 'string',
+ ),
+ 'slug' => array(
+ 'type' => 'string',
+ ),
+ ),
+ ),
+ ),
+ ),
+ )
+ );
+ register_theme_feature(
'editor-styles',
array(
'description' => __( 'Whether theme opts in to the editor styles CSS wrapper.' ),