Make WordPress Core

Changeset 48156


Ignore:
Timestamp:
06/24/2020 12:57:12 PM (4 years ago)
Author:
youknowriad
Message:

Block Editor: Add the Block Patterns API.

Backport WP_Block_Pattern_Categories_Registry, WP_Block_Patterns_Registry
and block patterns registration functions from the Gutenberg repository.

Props ocean90, ellatrix
Fixes #50445.

Location:
trunk/src
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-blocks.php

    r47240 r48156  
    284284
    285285$editor_settings = array(
    286     'alignWide'              => $align_wide,
    287     'availableTemplates'     => $available_templates,
    288     'allowedBlockTypes'      => $allowed_block_types,
    289     'disableCustomColors'    => get_theme_support( 'disable-custom-colors' ),
    290     'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),
    291     'disableCustomGradients' => get_theme_support( 'disable-custom-gradients' ),
    292     'disablePostFormats'     => ! current_theme_supports( 'post-formats' ),
     286    'alignWide'                            => $align_wide,
     287    'availableTemplates'                   => $available_templates,
     288    'allowedBlockTypes'                    => $allowed_block_types,
     289    'disableCustomColors'                  => get_theme_support( 'disable-custom-colors' ),
     290    'disableCustomFontSizes'               => get_theme_support( 'disable-custom-font-sizes' ),
     291    'disableCustomGradients'               => get_theme_support( 'disable-custom-gradients' ),
     292    'disablePostFormats'                   => ! current_theme_supports( 'post-formats' ),
    293293    /** This filter is documented in wp-admin/edit-form-advanced.php */
    294     'titlePlaceholder'       => apply_filters( 'enter_title_here', __( 'Add title' ), $post ),
    295     'bodyPlaceholder'        => $body_placeholder,
    296     'isRTL'                  => is_rtl(),
    297     'autosaveInterval'       => AUTOSAVE_INTERVAL,
    298     'maxUploadFileSize'      => $max_upload_size,
    299     'allowedMimeTypes'       => get_allowed_mime_types(),
    300     'styles'                 => $styles,
    301     'imageSizes'             => $available_image_sizes,
    302     'imageDimensions'        => $image_dimensions,
    303     'richEditingEnabled'     => user_can_richedit(),
    304     'postLock'               => $lock_details,
    305     'postLockUtils'          => array(
     294    'titlePlaceholder'                     => apply_filters( 'enter_title_here', __( 'Add title' ), $post ),
     295    'bodyPlaceholder'                      => $body_placeholder,
     296    'isRTL'                                => is_rtl(),
     297    'autosaveInterval'                     => AUTOSAVE_INTERVAL,
     298    'maxUploadFileSize'                    => $max_upload_size,
     299    'allowedMimeTypes'                     => get_allowed_mime_types(),
     300    'styles'                               => $styles,
     301    'imageSizes'                           => $available_image_sizes,
     302    'imageDimensions'                      => $image_dimensions,
     303    'richEditingEnabled'                   => user_can_richedit(),
     304    'postLock'                             => $lock_details,
     305    'postLockUtils'                        => array(
    306306        'nonce'       => wp_create_nonce( 'lock-post_' . $post->ID ),
    307307        'unlockNonce' => wp_create_nonce( 'update-post_' . $post->ID ),
    308308        'ajaxUrl'     => admin_url( 'admin-ajax.php' ),
    309309    ),
     310    '__experimentalBlockPatterns'          => WP_Block_Patterns_Registry::get_instance()->get_all_registered(),
     311    '__experimentalBlockPatternCategories' => WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered(),
    310312
    311313    // Whether or not to load the 'postcustom' meta box is stored as a user meta
    312314    // field so that we're not always loading its assets.
    313     'enableCustomFields'     => (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ),
     315    'enableCustomFields'                   => (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ),
    314316);
    315317
  • trunk/src/wp-settings.php

    r48072 r48156  
    275275require ABSPATH . WPINC . '/sitemaps/providers/class-wp-sitemaps-users.php';
    276276require ABSPATH . WPINC . '/class-wp-block-type.php';
     277require ABSPATH . WPINC . '/class-wp-block-pattern-categories-registry.php';
     278require ABSPATH . WPINC . '/class-wp-block-patterns-registry.php';
    277279require ABSPATH . WPINC . '/class-wp-block-styles-registry.php';
    278280require ABSPATH . WPINC . '/class-wp-block-type-registry.php';
Note: See TracChangeset for help on using the changeset viewer.