]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/theme.php
WordPress 4.7.1
[autoinstalls/wordpress.git] / wp-includes / theme.php
index 8aac86c9f795ef213ebee491ce4630e5c1d6ea62..84fdd23adbe5b7c67c5123c9919dd8eaf3d88262 100644 (file)
@@ -1554,7 +1554,7 @@ function _custom_background_cb() {
        $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' ) );
@@ -1643,7 +1643,8 @@ function wp_get_custom_css_post( $stylesheet = '' ) {
                '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;
@@ -1652,18 +1653,17 @@ function wp_get_custom_css_post( $stylesheet = '' ) {
 
                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 );
@@ -1787,9 +1787,15 @@ function wp_update_custom_css_post( $css, $args = array() ) {
        } 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 );
+                       }
                }
        }
 
@@ -1965,7 +1971,12 @@ function get_theme_starter_content() {
                        ) ),
                ),
                '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}}',