| @@ -8,227 +8,69 @@ | ||
| 8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | 9 | die( 'Silence is golden.' ); |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -define( 'IS_GUTENBERG_PLUGIN', true ); | |
| 13 | - | |
| 14 | -require_once __DIR__ . '/init.php'; | |
| 15 | -require_once __DIR__ . '/upgrade.php'; | |
| 16 | - | |
| 17 | -// Load auto-generated build registration. | |
| 18 | -$build_registration = plugin_dir_path( __DIR__ ) . 'build/build.php'; | |
| 19 | -if ( file_exists( $build_registration ) ) { | |
| 20 | - require_once $build_registration; | |
| 21 | -} | |
| 22 | - | |
| 23 | -// Define version constant for backwards compatibility. | |
| 24 | -// The constants.php file returns an array but doesn't define constants to avoid conflicts. | |
| 25 | -$constants_file = plugin_dir_path( __DIR__ ) . 'build/constants.php'; | |
| 26 | -if ( file_exists( $constants_file ) && ! defined( 'GUTENBERG_VERSION' ) ) { | |
| 27 | - $build_constants = require $constants_file; | |
| 28 | - define( 'GUTENBERG_VERSION', $build_constants['version'] ); | |
| 29 | -} | |
| 30 | - | |
| 31 | -/** | |
| 32 | - * Checks whether the Gutenberg experiment is enabled. | |
| 33 | - * | |
| 34 | - * @since 6.7.0 | |
| 35 | - * | |
| 36 | - * @param string $name The name of the experiment. | |
| 37 | - * | |
| 38 | - * @return bool True when the experiment is enabled. | |
| 39 | - */ | |
| 40 | -function gutenberg_is_experiment_enabled( $name ) { | |
| 41 | - // Special handling for active_templates - check if the active_templates option exists. | |
| 42 | - // This is not stored in the experiments array but as a separate option. | |
| 43 | - if ( 'active_templates' === $name ) { | |
| 44 | - return is_array( get_option( 'active_templates' ) ); | |
| 45 | - } | |
| 46 | - | |
| 47 | - $experiments = get_option( 'gutenberg-experiments' ); | |
| 48 | - return ! empty( $experiments[ $name ] ); | |
| 49 | -} | |
| 50 | - | |
| 51 | -// These files only need to be loaded if within a rest server instance. | |
| 12 | +// These files only need to be loaded if within a rest server instance | |
| 52 | 13 | // which this class will exist if that is the case. |
| 53 | 14 | if ( class_exists( 'WP_REST_Controller' ) ) { |
| 54 | - if ( ! class_exists( 'WP_REST_Block_Editor_Settings_Controller' ) ) { | |
| 55 | - require_once __DIR__ . '/experimental/class-wp-rest-block-editor-settings-controller.php'; | |
| 15 | + if ( ! class_exists( 'WP_REST_Blocks_Controller' ) ) { | |
| 16 | + require dirname( __FILE__ ) . '/class-wp-rest-blocks-controller.php'; | |
| 56 | 17 | } |
| 18 | + if ( ! class_exists( 'WP_REST_Autosaves_Controller' ) ) { | |
| 19 | + require dirname( __FILE__ ) . '/class-wp-rest-autosaves-controller.php'; | |
| 20 | + } | |
| 21 | + if ( ! class_exists( 'WP_REST_Themes_Controller' ) ) { | |
| 22 | + require dirname( __FILE__ ) . '/class-wp-rest-themes-controller.php'; | |
| 23 | + } | |
| 24 | + if ( ! class_exists( 'WP_REST_Block_Renderer_Controller' ) ) { | |
| 25 | + require dirname( __FILE__ ) . '/class-wp-rest-block-renderer-controller.php'; | |
| 26 | + } | |
| 27 | + if ( ! class_exists( 'WP_REST_Search_Controller' ) ) { | |
| 28 | + require dirname( __FILE__ ) . '/class-wp-rest-search-controller.php'; | |
| 29 | + } | |
| 30 | + if ( ! class_exists( 'WP_REST_Search_Handler' ) ) { | |
| 31 | + require dirname( __FILE__ ) . '/class-wp-rest-search-handler.php'; | |
| 32 | + } | |
| 33 | + if ( ! class_exists( 'WP_REST_Post_Search_Handler' ) ) { | |
| 34 | + require dirname( __FILE__ ) . '/class-wp-rest-post-search-handler.php'; | |
| 35 | + } | |
| 57 | 36 | |
| 58 | - // WordPress 7.0 compat. | |
| 59 | - require __DIR__ . '/compat/wordpress-7.0/class-gutenberg-rest-autosaves-controller.php'; | |
| 60 | - require __DIR__ . '/compat/wordpress-7.0/class-gutenberg-rest-revisions-controller.php'; | |
| 61 | - require __DIR__ . '/compat/wordpress-7.0/class-gutenberg-rest-block-patterns-controller-7-0.php'; | |
| 62 | - require __DIR__ . '/compat/wordpress-7.0/class-gutenberg-rest-templates-controller-7-0.php'; | |
| 63 | - require __DIR__ . '/compat/wordpress-7.0/class-gutenberg-rest-static-templates-controller.php'; | |
| 64 | - require __DIR__ . '/compat/wordpress-7.0/class-wp-icons-registry.php'; | |
| 65 | - require __DIR__ . '/compat/wordpress-7.0/class-wp-rest-icons-controller.php'; | |
| 66 | - require __DIR__ . '/compat/wordpress-7.0/template-activate.php'; | |
| 67 | - require __DIR__ . '/compat/wordpress-7.0/rest-api.php'; | |
| 68 | - require __DIR__ . '/compat/wordpress-7.0/global-styles.php'; | |
| 37 | + require dirname( __FILE__ ) . '/rest-api.php'; | |
| 38 | +} | |
| 69 | 39 | |
| 70 | - // WordPress 7.1 compat. | |
| 71 | - require __DIR__ . '/compat/wordpress-7.1/class-gutenberg-rest-attachments-controller-7-1.php'; | |
| 72 | - require __DIR__ . '/compat/wordpress-7.1/view-config-api.php'; | |
| 73 | - require __DIR__ . '/compat/wordpress-7.1/class-gutenberg-rest-view-config-controller-7-1.php'; | |
| 74 | - require __DIR__ . '/compat/wordpress-7.1/rest-api.php'; | |
| 75 | - require __DIR__ . '/compat/wordpress-7.1/collaboration.php'; | |
| 76 | - require __DIR__ . '/compat/wordpress-7.1/block-bindings.php'; | |
| 77 | - | |
| 78 | - // Plugin specific code. | |
| 79 | - require_once __DIR__ . '/class-wp-rest-global-styles-controller-gutenberg.php'; | |
| 80 | - require_once __DIR__ . '/class-wp-rest-edit-site-export-controller-gutenberg.php'; | |
| 81 | - require_once __DIR__ . '/class-wp-icons-registry-gutenberg.php'; | |
| 82 | - require_once __DIR__ . '/class-wp-rest-icons-controller-gutenberg.php'; | |
| 83 | - require_once __DIR__ . '/rest-api.php'; | |
| 84 | - | |
| 85 | - // Experimental autosaves controller override for real-time collaboration. | |
| 86 | - | |
| 87 | - require_once __DIR__ . '/experimental/rest-api.php'; | |
| 88 | - require_once __DIR__ . '/experimental/kses-allowed-html.php'; | |
| 89 | - | |
| 90 | - require_once __DIR__ . '/experimental/class-gutenberg-hierarchical-sort.php'; | |
| 40 | +require dirname( __FILE__ ) . '/meta-box-partial-page.php'; | |
| 41 | +if ( ! class_exists( 'WP_Block_Type' ) ) { | |
| 42 | + require dirname( __FILE__ ) . '/class-wp-block-type.php'; | |
| 91 | 43 | } |
| 92 | - | |
| 93 | -require_once __DIR__ . '/remove-core-enqueue-scripts.php'; | |
| 94 | -require_once __DIR__ . '/experimental/editor-settings.php'; | |
| 95 | -require_once __DIR__ . '/experimental/rest-api-overrides.php'; | |
| 96 | - | |
| 97 | -// Gutenberg plugin compat. | |
| 98 | -require __DIR__ . '/compat/plugin/edit-site-routes-backwards-compat.php'; | |
| 99 | -require __DIR__ . '/compat/plugin/fonts.php'; | |
| 100 | -require __DIR__ . '/compat/plugin/style-state-aliases.php'; | |
| 101 | - | |
| 102 | - | |
| 103 | -// WordPress 7.0 compat. | |
| 104 | -require __DIR__ . '/compat/wordpress-7.0/preload.php'; | |
| 105 | -require __DIR__ . '/compat/wordpress-7.0/auto-register.php'; | |
| 106 | -require __DIR__ . '/compat/wordpress-7.0/blocks.php'; | |
| 107 | -require __DIR__ . '/compat/wordpress-7.0/kses.php'; | |
| 108 | -require __DIR__ . '/compat/wordpress-7.0/command-palette.php'; | |
| 109 | -require __DIR__ . '/compat/wordpress-7.0/meta-box-rtc-compat.php'; | |
| 110 | -require __DIR__ . '/compat/wordpress-7.0/script-modules.php'; | |
| 111 | -require __DIR__ . '/compat/wordpress-7.0/fonts.php'; | |
| 112 | - | |
| 113 | -if ( class_exists( '\WordPress\AiClient\AiClient' ) ) { | |
| 114 | - require __DIR__ . '/compat/wordpress-7.0/class-wp-connector-registry.php'; | |
| 115 | - require __DIR__ . '/compat/wordpress-7.0/connectors.php'; | |
| 116 | - require __DIR__ . '/compat/wordpress-7.0/default-connectors.php'; | |
| 44 | +if ( ! class_exists( 'WP_Block_Type_Registry' ) ) { | |
| 45 | + require dirname( __FILE__ ) . '/class-wp-block-type-registry.php'; | |
| 117 | 46 | } |
| 47 | +require dirname( __FILE__ ) . '/blocks.php'; | |
| 48 | +require dirname( __FILE__ ) . '/client-assets.php'; | |
| 49 | +require dirname( __FILE__ ) . '/compat.php'; | |
| 50 | +require dirname( __FILE__ ) . '/plugin-compat.php'; | |
| 51 | +require dirname( __FILE__ ) . '/i18n.php'; | |
| 52 | +require dirname( __FILE__ ) . '/register.php'; | |
| 118 | 53 | |
| 119 | -// WordPress 7.1 compat. | |
| 120 | -require __DIR__ . '/compat/wordpress-7.1/kses.php'; | |
| 121 | -require __DIR__ . '/compat/wordpress-7.1/media.php'; | |
| 122 | -require __DIR__ . '/compat/wordpress-7.1/preload.php'; | |
| 123 | 54 | |
| 124 | -// Experimental features. | |
| 125 | -require __DIR__ . '/experimental/omnibar/load.php'; | |
| 126 | -require __DIR__ . '/experimental/block-editor-settings-mobile.php'; | |
| 127 | -require __DIR__ . '/experimental/blocks.php'; | |
| 128 | -require __DIR__ . '/experimental/navigation-theme-opt-in.php'; | |
| 129 | -require __DIR__ . '/experimental/kses.php'; | |
| 130 | -require __DIR__ . '/experimental/script-modules.php'; | |
| 131 | -require __DIR__ . '/experimental/pages/site-editor.php'; | |
| 132 | -require __DIR__ . '/experimental/extensible-site-editor.php'; | |
| 133 | -if ( gutenberg_is_experiment_enabled( 'gutenberg-media-editor' ) ) { | |
| 134 | - require __DIR__ . '/experimental/media-editor/load.php'; | |
| 55 | +// Register server-side code for individual blocks. | |
| 56 | +if ( ! function_exists( 'render_block_core_archives' ) ) { | |
| 57 | + require dirname( __FILE__ ) . '/../packages/block-library/src/archives/index.php'; | |
| 135 | 58 | } |
| 136 | - | |
| 137 | -if ( gutenberg_is_experiment_enabled( 'gutenberg-workflow-palette' ) ) { | |
| 138 | - require __DIR__ . '/experimental/workflow-palette.php'; | |
| 59 | +if ( ! function_exists( 'render_block_core_block' ) ) { | |
| 60 | + require dirname( __FILE__ ) . '/../packages/block-library/src/block/index.php'; | |
| 139 | 61 | } |
| 140 | - | |
| 141 | -// Load the BC Layer to avoid fatal errors of extenders using the Fonts API. | |
| 142 | -// @core-merge: do not merge the BC layer files into WordPress Core. | |
| 143 | -require __DIR__ . '/experimental/font-face/bc-layer/class-wp-fonts-provider.php'; | |
| 144 | -require __DIR__ . '/experimental/font-face/bc-layer/class-wp-fonts-utils.php'; | |
| 145 | -require __DIR__ . '/experimental/font-face/bc-layer/class-wp-fonts.php'; | |
| 146 | -require __DIR__ . '/experimental/font-face/bc-layer/class-wp-fonts-provider-local.php'; | |
| 147 | -require __DIR__ . '/experimental/font-face/bc-layer/class-wp-fonts-resolver.php'; | |
| 148 | -require __DIR__ . '/experimental/font-face/bc-layer/class-gutenberg-fonts-api-bc-layer.php'; | |
| 149 | -require __DIR__ . '/experimental/font-face/bc-layer/webfonts-deprecations.php'; | |
| 150 | -require __DIR__ . '/experimental/font-face/bc-layer/class-wp-webfonts-utils.php'; | |
| 151 | -require __DIR__ . '/experimental/font-face/bc-layer/class-wp-webfonts-provider.php'; | |
| 152 | -require __DIR__ . '/experimental/font-face/bc-layer/class-wp-webfonts-provider-local.php'; | |
| 153 | -require __DIR__ . '/experimental/font-face/bc-layer/class-wp-webfonts.php'; | |
| 154 | -require __DIR__ . '/experimental/font-face/bc-layer/class-wp-web-fonts.php'; | |
| 155 | - | |
| 156 | -// Plugin specific code. | |
| 157 | -require __DIR__ . '/script-loader.php'; | |
| 158 | -require __DIR__ . '/global-styles-and-settings.php'; | |
| 159 | -require __DIR__ . '/class-wp-theme-json-data-gutenberg.php'; | |
| 160 | -require __DIR__ . '/class-wp-theme-json-gutenberg.php'; | |
| 161 | -require __DIR__ . '/class-wp-theme-json-resolver-gutenberg.php'; | |
| 162 | -require __DIR__ . '/class-wp-theme-json-schema-gutenberg.php'; | |
| 163 | -require __DIR__ . '/class-wp-duotone-gutenberg.php'; | |
| 164 | -require __DIR__ . '/blocks.php'; | |
| 165 | -require __DIR__ . '/block-editor-settings.php'; | |
| 166 | -require __DIR__ . '/client-assets.php'; | |
| 167 | -require __DIR__ . '/mathml-kses.php'; | |
| 168 | -require __DIR__ . '/demo.php'; | |
| 169 | -require __DIR__ . '/experimental/experiments/load.php'; | |
| 170 | -require __DIR__ . '/interactivity-api.php'; | |
| 171 | -require __DIR__ . '/block-template-utils.php'; | |
| 172 | - | |
| 173 | -// Copied package PHP files. | |
| 174 | -if ( is_dir( __DIR__ . '/../build/scripts/style-engine' ) ) { | |
| 175 | - require_once __DIR__ . '/../build/scripts/style-engine/class-wp-style-engine-css-declarations-gutenberg.php'; | |
| 176 | - require_once __DIR__ . '/../build/scripts/style-engine/class-wp-style-engine-css-rule-gutenberg.php'; | |
| 177 | - require_once __DIR__ . '/../build/scripts/style-engine/class-wp-style-engine-css-rules-store-gutenberg.php'; | |
| 178 | - require_once __DIR__ . '/../build/scripts/style-engine/class-wp-style-engine-processor-gutenberg.php'; | |
| 179 | - require_once __DIR__ . '/../build/scripts/style-engine/class-wp-style-engine-gutenberg.php'; | |
| 180 | - require_once __DIR__ . '/../build/scripts/style-engine/style-engine-gutenberg.php'; | |
| 62 | +if ( ! function_exists( 'render_block_core_categories' ) ) { | |
| 63 | + require dirname( __FILE__ ) . '/../packages/block-library/src/categories/index.php'; | |
| 181 | 64 | } |
| 182 | - | |
| 183 | -// Block supports overrides. | |
| 184 | -require __DIR__ . '/block-supports/settings.php'; | |
| 185 | -require __DIR__ . '/block-supports/elements.php'; | |
| 186 | -require __DIR__ . '/block-supports/colors.php'; | |
| 187 | -require __DIR__ . '/block-supports/typography.php'; | |
| 188 | -require __DIR__ . '/block-supports/border.php'; | |
| 189 | -require __DIR__ . '/block-supports/layout.php'; | |
| 190 | -require __DIR__ . '/block-supports/position.php'; | |
| 191 | -require __DIR__ . '/block-supports/spacing.php'; | |
| 192 | -require __DIR__ . '/block-supports/dimensions.php'; | |
| 193 | -require __DIR__ . '/block-supports/duotone.php'; | |
| 194 | -require __DIR__ . '/block-supports/shadow.php'; | |
| 195 | -require __DIR__ . '/block-supports/background.php'; | |
| 196 | -require __DIR__ . '/block-supports/block-style-variations.php'; | |
| 197 | -require __DIR__ . '/block-supports/aria-label.php'; | |
| 198 | -require __DIR__ . '/block-supports/anchor.php'; | |
| 199 | -require __DIR__ . '/block-supports/block-visibility.php'; | |
| 200 | -require __DIR__ . '/block-supports/custom-css.php'; | |
| 201 | -require __DIR__ . '/block-supports/states.php'; | |
| 202 | - | |
| 203 | -// Client-side media processing. | |
| 204 | -require_once __DIR__ . '/media/load.php'; | |
| 205 | - | |
| 206 | -// Interactivity API full-page client-side navigation. | |
| 207 | -if ( gutenberg_is_experiment_enabled( 'gutenberg-full-page-client-side-navigation' ) ) { | |
| 208 | - require __DIR__ . '/experimental/interactivity-api/class-gutenberg-interactivity-api-full-page-navigation.php'; | |
| 209 | - Gutenberg_Interactivity_API_Full_Page_Navigation::instance(); | |
| 65 | +// Currently merged in core as `gutenberg_render_block_core_latest_comments`, | |
| 66 | +// expected to change soon. | |
| 67 | +if ( ! function_exists( 'render_block_core_latest_comments' ) | |
| 68 | + && ! function_exists( 'gutenberg_render_block_core_latest_comments' ) ) { | |
| 69 | + require dirname( __FILE__ ) . '/../packages/block-library/src/latest-comments/index.php'; | |
| 210 | 70 | } |
| 211 | - | |
| 212 | -// Block patterns for navigation overlays. | |
| 213 | -require __DIR__ . '/overlay-patterns.php'; | |
| 214 | - | |
| 215 | -// Guidelines (only load when experiment is enabled). | |
| 216 | -if ( gutenberg_is_experiment_enabled( 'gutenberg-guidelines' ) ) { | |
| 217 | - require __DIR__ . '/experimental/guidelines/load.php'; | |
| 218 | - require __DIR__ . '/experimental/guidelines/index.php'; | |
| 71 | +if ( ! function_exists( 'render_block_core_latest_posts' ) ) { | |
| 72 | + require dirname( __FILE__ ) . '/../packages/block-library/src/latest-posts/index.php'; | |
| 219 | 73 | } |
| 220 | - | |
| 221 | -// Content types (only load when experiment is enabled). | |
| 222 | -if ( gutenberg_is_experiment_enabled( 'gutenberg-content-types' ) ) { | |
| 223 | - require __DIR__ . '/experimental/content-types/load.php'; | |
| 224 | - require __DIR__ . '/experimental/content-types/index.php'; | |
| 225 | - require __DIR__ . '/experimental/content-types/post-types.php'; | |
| 226 | -} | |
| 227 | - | |
| 228 | -// Dashboard Widgets (only load when experiment is enabled). | |
| 229 | -if ( gutenberg_is_experiment_enabled( 'gutenberg-dashboard-widgets' ) ) { | |
| 230 | - require __DIR__ . '/experimental/dashboard-widgets/load.php'; | |
| 231 | - require __DIR__ . '/experimental/dashboard-widgets/widget-types.php'; | |
| 232 | - require __DIR__ . '/experimental/dashboard-widgets/dashboard-layout.php'; | |
| 233 | - require __DIR__ . '/experimental/dashboard-widgets/default-layout-seed.php'; | |
| 74 | +if ( ! function_exists( 'render_block_core_shortcode' ) ) { | |
| 75 | + require dirname( __FILE__ ) . '/../packages/block-library/src/shortcode/index.php'; | |
| 234 | 76 | } |