$style = $color ? "background-color: #$color;" : '';
if ( $background ) {
- $image = " background-image: url(" . wp_json_encode( $background ) . ");";
+ $image = ' background-image: url("' . esc_url_raw( $background ) . '");';
// Background Position.
$position_x = get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) );
'no_found_rows' => true,
'cache_results' => true,
'update_post_meta_cache' => false,
- 'update_term_meta_cache' => false,
+ 'update_post_term_cache' => false,
+ 'lazy_load_term_meta' => false,
);
$post = null;
if ( $post_id > 0 && get_post( $post_id ) ) {
$post = get_post( $post_id );
- } else {
+ }
+
+ // `-1` indicates no post exists; no query necessary.
+ if ( ! $post && -1 !== $post_id ) {
$query = new WP_Query( $custom_css_query_vars );
$post = $query->post;
/*
- * Cache the lookup. See WP_Customize_Custom_CSS_Setting::update().
+ * Cache the lookup. See wp_update_custom_css_post().
* @todo This should get cleared if a custom_css post is added/removed.
*/
- if ( $post ) {
- set_theme_mod( 'custom_css_post_id', $post->ID );
- } elseif ( -1 !== $post_id ) {
- set_theme_mod( 'custom_css_post_id', -1 );
- }
+ set_theme_mod( 'custom_css_post_id', $post ? $post->ID : -1 );
}
} else {
$query = new WP_Query( $custom_css_query_vars );
} else {
$r = wp_insert_post( wp_slash( $post_data ), true );
- // Trigger creation of a revision. This should be removed once #30854 is resolved.
- if ( ! is_wp_error( $r ) && 0 === count( wp_get_post_revisions( $r ) ) ) {
- wp_save_post_revision( $r );
+ if ( ! is_wp_error( $r ) ) {
+ if ( get_stylesheet() === $args['stylesheet'] ) {
+ set_theme_mod( 'custom_css_post_id', $r );
+ }
+
+ // Trigger creation of a revision. This should be removed once #30854 is resolved.
+ if ( 0 === count( wp_get_post_revisions( $r ) ) ) {
+ wp_save_post_revision( $r );
+ }
}
}
) ),
),
'nav_menus' => array(
- 'page_home' => array(
+ 'link_home' => array(
+ 'type' => 'custom',
+ 'title' => _x( 'Home', 'Theme starter content' ),
+ 'url' => home_url(),
+ ),
+ 'page_home' => array( // Deprecated in favor of home_link.
'type' => 'post_type',
'object' => 'page',
'object_id' => '{{home}}',