From 240e138d814d221ef896c2783f710b0d1c3594af Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Tue, 29 Jan 2019 11:36:32 -0500 Subject: [PATCH] Plugin: Populate demo content by default content filters (#13553) * Plugin: Populate demo content by default content filters * Plugin: Avoid checking post status on default content Assumed to be called only in the process of generating a new post for edit (the same assumption checked by testing 'auto-draft' status) * Plugin: Remove unreachable initial_edits code --- gutenberg.php | 13 --------- lib/client-assets.php | 14 +--------- lib/demo.php | 64 +++++++++++++++++++++++++++++++++++++++++++ lib/load.php | 2 +- 4 files changed, 66 insertions(+), 27 deletions(-) create mode 100644 lib/demo.php diff --git a/gutenberg.php b/gutenberg.php index f91df4b918597..502469ba2f421 100644 --- a/gutenberg.php +++ b/gutenberg.php @@ -254,19 +254,6 @@ function gutenberg_init( $return, $post ) { return true; } -/** - * Redirects the demo page to edit a new post. - */ -function gutenberg_redirect_demo() { - global $pagenow; - - if ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'gutenberg' === $_GET['page'] ) { - wp_safe_redirect( admin_url( 'post-new.php?gutenberg-demo' ) ); - exit; - } -} -add_action( 'admin_init', 'gutenberg_redirect_demo' ); - /** * Adds the filters to register additional links for the Gutenberg editor in * the post/page screens. diff --git a/lib/client-assets.php b/lib/client-assets.php index 4fff23ed4bdf5..634c5352e6e16 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -865,8 +865,6 @@ function gutenberg_get_available_image_sizes() { * @param string $hook Screen name. */ function gutenberg_editor_scripts_and_styles( $hook ) { - $is_demo = isset( $_GET['gutenberg-demo'] ); - global $wp_scripts, $wp_meta_boxes; // Add "wp-hooks" as dependency of "heartbeat". @@ -983,17 +981,7 @@ function gutenberg_editor_scripts_and_styles( $hook ) { // Assign initial edits, if applicable. These are not initially assigned // to the persisted post, but should be included in its save payload. - if ( $is_new_post && $is_demo ) { - // Prepopulate with some test content in demo. - ob_start(); - include gutenberg_dir_path() . 'post-content.php'; - $demo_content = ob_get_clean(); - - $initial_edits = array( - 'title' => __( 'Welcome to the Gutenberg Editor', 'gutenberg' ), - 'content' => $demo_content, - ); - } elseif ( $is_new_post ) { + if ( $is_new_post ) { // Override "(Auto Draft)" new post default title with empty string, // or filtered value. $initial_edits = array( diff --git a/lib/demo.php b/lib/demo.php new file mode 100644 index 0000000000000..11272050bf4c2 --- /dev/null +++ b/lib/demo.php @@ -0,0 +1,64 @@ +