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 / upgrade.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

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

89 lines 2.6 KB Raw Download Zip
1 <?php
2 /**
3 * Upgrading Gutenberg's database.
4 *
5 * @package gutenberg
6 */
7
8 if ( ! defined( '_GUTENBERG_VERSION_MIGRATION' ) ) {
9 // It's necessary to update this version every time a new migration is needed.
10 define( '_GUTENBERG_VERSION_MIGRATION', '22.8.0' );
11 }
12
13 /**
14 * Migrate Gutenberg's database on upgrade.
15 *
16 * @access private
17 * @internal
18 */
19 function _gutenberg_migrate_database() {
20 // The default value used here is the first version before migrations were added.
21 $gutenberg_installed_version = get_option( 'gutenberg_version_migration', '9.7.0' );
22
23 if ( _GUTENBERG_VERSION_MIGRATION !== $gutenberg_installed_version ) {
24 if ( version_compare( $gutenberg_installed_version, '9.8.0', '<' ) ) {
25 _gutenberg_migrate_remove_fse_drafts();
26 }
27
28 if ( version_compare( $gutenberg_installed_version, '22.8.0', '<' ) ) {
29 _gutenberg_migrate_enable_real_time_collaboration();
30 }
31
32 update_option( 'gutenberg_version_migration', _GUTENBERG_VERSION_MIGRATION );
33 }
34 }
35
36 /**
37 * Remove FSE auto drafts and associated terms.
38 *
39 * @access private
40 * @internal
41 */
42 function _gutenberg_migrate_remove_fse_drafts() {
43 // Delete auto-draft templates and template parts.
44 $delete_query = new WP_Query(
45 array(
46 'post_status' => array( 'auto-draft' ),
47 'post_type' => array( 'wp_template', 'wp_template_part' ),
48 'posts_per_page' => -1,
49 )
50 );
51 foreach ( $delete_query->posts as $post ) {
52 wp_delete_post( $post->ID, true );
53 }
54
55 // Delete _wp_file_based term.
56 $term = get_term_by( 'name', '_wp_file_based', 'wp_theme' );
57 if ( $term ) {
58 wp_delete_term( $term->term_id, 'wp_theme' );
59 }
60
61 // Delete useless options.
62 delete_option( 'gutenberg_last_synchronize_theme_template_checks' );
63 delete_option( 'gutenberg_last_synchronize_theme_template-part_checks' );
64 }
65
66 /**
67 * Update RTC option name.
68 *
69 * @since 22.8.0
70 */
71 function _gutenberg_migrate_enable_real_time_collaboration() {
72 $value1 = get_option( 'enable_real_time_collaboration', '1' );
73 $value2 = get_option( 'wp_enable_real_time_collaboration', '1' );
74
75 // RTC is enabled by default in the plugin, so only set the value if it was
76 // previously disabled. Otherwise rely on the default value.
77 if ( ! $value1 || ! $value2 ) {
78 update_option( 'wp_collaboration_enabled', '0' );
79 }
80
81 delete_option( 'enable_real_time_collaboration' );
82 delete_option( 'wp_enable_real_time_collaboration' );
83 }
84
85 // Deletion of the `_wp_file_based` term (in _gutenberg_migrate_remove_fse_drafts) must happen
86 // after its taxonomy (`wp_theme`) is registered. This happens in `gutenberg_register_wp_theme_taxonomy`,
87 // which is hooked into `init` (default priority, i.e. 10).
88 add_action( 'init', '_gutenberg_migrate_database', 20 );
89