PluginProbe
Gutenberg / 23.2.0
Gutenberg v23.2.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / lib / demo.php
lib
block-supports 4 months ago compat 3 months ago experimental 3 months ago media 3 months ago README.md 10.0 KB 7 months ago block-editor-settings.php 5.4 KB 7 months ago block-template-utils.php 3.5 KB 1 year ago blocks.php 11.8 KB 7 months ago class-wp-duotone-gutenberg.php 37.6 KB 5 months ago class-wp-icons-registry-gutenberg.php 7.1 KB 4 months ago class-wp-rest-edit-site-export-controller-gutenberg.php 1.2 KB 2 years ago class-wp-rest-global-styles-controller-gutenberg.php 24.5 KB 7 months ago class-wp-rest-icons-controller-gutenberg.php 481 B 4 months ago class-wp-theme-json-data-gutenberg.php 1.7 KB 2 years ago class-wp-theme-json-gutenberg.php 196.1 KB 3 months ago class-wp-theme-json-resolver-gutenberg.php 34.7 KB 6 months ago class-wp-theme-json-schema-gutenberg.php 7.4 KB 7 months ago client-assets.php 16.4 KB 4 months ago demo.php 1.6 KB 1 year ago global-styles-and-settings.php 14.2 KB 7 months ago init.php 945 B 4 months ago interactivity-api.php 1.2 KB 7 months ago load.php 10.9 KB 3 months ago mathml-kses.php 6.3 KB 10 months ago overlay-patterns.php 12.2 KB 6 months ago remove-core-enqueue-scripts.php 779 B 5 months ago rest-api.php 1.6 KB 4 months ago script-loader.php 5.9 KB 5 months ago theme-i18n.json 1.8 KB 7 months ago theme.json 9.2 KB 5 months ago upgrade.php 2.6 KB 5 months ago

demo.php in Gutenberg 23.2.0, at lib/demo.php

67 lines 1.6 KB Raw Download Zip
1 <?php
2 /**
3 * Supports for populating the Gutenberg demo content new post.
4 *
5 * @package gutenberg
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 die( 'Silence is golden.' );
10 }
11
12 /**
13 * Redirects the demo page to edit a new post.
14 *
15 * @global string $pagenow The name of the current admin page being viewed.
16 */
17 function gutenberg_redirect_demo() {
18 global $pagenow;
19
20 if ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'gutenberg' === $_GET['page'] ) {
21 wp_safe_redirect( admin_url( 'post-new.php?gutenberg-demo' ) );
22 exit;
23 }
24 }
25 add_action( 'admin_init', 'gutenberg_redirect_demo' );
26
27 /**
28 * Assigns the default content for the Gutenberg demo post.
29 *
30 * @param string $content Default post content.
31 *
32 * @return string Demo content if creating a new Gutenberg demo post, or the
33 * default content otherwise.
34 */
35 function gutenberg_default_demo_content( $content ) {
36 $is_demo = isset( $_GET['gutenberg-demo'] );
37
38 if ( $is_demo ) {
39 // Prepopulate with some test content in demo.
40 ob_start();
41 include gutenberg_dir_path() . 'post-content.php';
42 return ob_get_clean();
43 }
44
45 return $content;
46 }
47 add_filter( 'default_content', 'gutenberg_default_demo_content' );
48
49 /**
50 * Assigns the default title for the Gutenberg demo post.
51 *
52 * @param string $title Default post title.
53 *
54 * @return string Demo title if creating a new Gutenberg demo post, or the
55 * default title otherwise.
56 */
57 function gutenberg_default_demo_title( $title ) {
58 $is_demo = isset( $_GET['gutenberg-demo'] );
59
60 if ( $is_demo ) {
61 return __( 'Welcome to the Gutenberg Editor', 'gutenberg' );
62 }
63
64 return $title;
65 }
66 add_filter( 'default_title', 'gutenberg_default_demo_title' );
67