From 8f1a4c9a560396e8d228c19c59414e76dfa65905 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sun, 4 Dec 2016 17:33:40 +0000 Subject: [PATCH] Customize: Ensure a `custom_css` post insertion gets an initial post revision. Merges [39477] onto 4.7 branch. Props georgestephanis, westonruter. Fixes #39032 for 4.7. Built from https://develop.svn.wordpress.org/branches/4.7@39479 git-svn-id: http://core.svn.wordpress.org/branches/4.7@39419 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/theme.php | 7 ++++++- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/wp-includes/theme.php b/wp-includes/theme.php index cf1bb0fa33..8aac86c9f7 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1786,9 +1786,14 @@ function wp_update_custom_css_post( $css, $args = array() ) { $r = wp_update_post( wp_slash( $post_data ), true ); } 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 ( $r instanceof WP_Error ) { + if ( is_wp_error( $r ) ) { return $r; } return get_post( $r ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 1cc35da079..3461458231 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-RC2-39476'; +$wp_version = '4.7-RC2-39479'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.