Skip to content

Commit

Permalink
prep build 10/20
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Oct 20, 2021
2 parents 13cb9bb + 1a3bda1 commit 57ea53d
Show file tree
Hide file tree
Showing 106 changed files with 1,781 additions and 220 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build-plugin-zip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ jobs:
old_version: ${{ steps.get_version.outputs.old_version }}
new_version: ${{ steps.get_version.outputs.new_version }}
release_branch: ${{ steps.get_version.outputs.release_branch }}
release_branch_commit: ${{ steps.commit_version_bump_to_release_branch.outputs.version_bump_commit }}
trunk_commit: ${{ steps.commit_version_bump_to_trunk.outputs.version_bump_commit }}

steps:
- name: Checkout code
Expand Down Expand Up @@ -125,23 +127,27 @@ jobs:
sed -i "s/${{ steps.get_version.outputs.old_version }}/${VERSION}/g" readme.txt
- name: Commit the version bump to the release branch
id: commit_version_bump_to_release_branch
run: |
git add gutenberg.php package.json package-lock.json readme.txt
git commit -m "Bump plugin version to ${{ steps.get_version.outputs.new_version }}"
git push --set-upstream origin "${{ steps.get_version.outputs.release_branch }}"
echo "::set-output name=version_bump_commit::$(git rev-parse --verify --short HEAD)"
- name: Fetch trunk
if: ${{ github.ref != 'refs/heads/trunk' }}
run: git fetch --depth=1 origin trunk

- name: Cherry-pick the version bump commit to trunk
id: commit_version_bump_to_trunk
run: |
git checkout trunk
git pull
TRUNK_VERSION=$(jq --raw-output '.version' package.json)
if [[ ${{ steps.get_version.outputs.old_version }} == "$TRUNK_VERSION" ]]; then
git cherry-pick "${{ steps.get_version.outputs.release_branch }}"
git push
echo "::set-output name=version_bump_commit::$(git rev-parse --verify --short HEAD)"
fi
build:
Expand All @@ -154,6 +160,8 @@ jobs:
github.event_name == 'workflow_dispatch' ||
github.repository == 'WordPress/gutenberg'
)
outputs:
job_status: ${{ job.status }}

steps:
- name: Checkout code
Expand Down Expand Up @@ -201,6 +209,51 @@ jobs:
name: release-notes
path: ./release-notes.txt

revert-version-bump:
name: Revert version bump if build failed
needs: [bump-version, build]
runs-on: ubuntu-latest
if: |
always() &&
( needs.build.outputs.job_status == 'failure' ) &&
needs.bump-version.outputs.release_branch_commit
steps:
- name: Checkout code
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
with:
fetch-depth: 2
ref: ${{ needs.bump-version.outputs.release_branch }}
token: ${{ secrets.GUTENBERG_TOKEN }}

- name: Configure git user name and email
run: |
git config user.name "Gutenberg Repository Automation"
git config user.email [email protected]
- name: Revert version bump commit on release branch
if: |
github.event.inputs.version == 'stable' ||
contains( needs.bump-version.outputs.old_version, 'rc' )
run: |
git revert --no-edit ${{ needs.bump-version.outputs.release_branch_commit }}
git push --set-upstream origin "${{ needs.bump-version.outputs.release_branch }}"
- name: Delete release branch if it was only just created for the RC
if: |
github.event.inputs.version == 'rc' &&
! contains( needs.bump-version.outputs.old_version, 'rc' )
run: |
git push origin :"${{ needs.bump-version.outputs.release_branch }}"
- name: Revert version bump on trunk
if: ${{ needs.bump-version.outputs.trunk_commit }}
run: |
git fetch --depth=2 origin trunk
git checkout trunk
git revert --no-edit ${{ needs.bump-version.outputs.trunk_commit }}
git push --set-upstream origin trunk
create-release:
name: Create Release Draft and Attach Asset
needs: [bump-version, build]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ concurrency:

jobs:
test:
runs-on: macos-latest
runs-on: macos-11
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
strategy:
matrix:
xcode: [12.2]
xcode: [12.5.1]
native-test-name: [gutenberg-editor-initial-html]
node: ['14']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ const ALLOWED_BLOCKS = [ 'core/image', 'core/paragraph' ];

## Orientation

By default, `InnerBlocks` expects its blocks to be shown in a vertical list. A valid use-case is to style InnerBlocks to appear horizontally. When blocks are styled in such a way, the `orientation` prop can be used to indicate a horizontal layout:
By default, `InnerBlocks` expects its blocks to be shown in a vertical list. A valid use-case is to style inner blocks to appear horizontally, for instance by adding CSS flex or grid properties to the inner blocks wrapper. When blocks are styled in such a way, the `orientation` prop can be set to indicate that a horizontal layout is being used:

```js
<InnerBlocks orientation="horizontal" />
```

Specifying this prop will result in the block movers being shown horizontally, and also ensure drag and drop works correctly.
Specifying this prop does not affect the layout of the inner blocks, but results in the block mover icons in the child blocks being displayed horizontally, and also ensures that drag and drop works correctly.

## Template

Expand Down
9 changes: 9 additions & 0 deletions docs/how-to-guides/themes/theme-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,15 @@ Currently block variations exist for "header" and "footer" values of the area te
}
```

## Developing with theme.json

It can be difficult to remember the theme.json settings and properties while you develop, so a JSON scheme was created to help. The schema is available at [SchemaStore.org](https://schemastore.org/)

To use the schema, add `"$schema": "https://json.schemastore.org/theme-v1.json"` to the beginning of your theme.json file. Visual Studio Code and other editors will pick up the schema and can provide help like tooltips, autocomplete, or schema validation in the editor.

![Example using validation with schema](https://developer.wordpress.org/files/2021/10/schema-validation.gif)


## Frequently Asked Questions

### The naming schema of CSS Custom Properties
Expand Down
38 changes: 16 additions & 22 deletions lib/class-wp-rest-menu-items-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -750,29 +750,23 @@ public function prepare_item_for_response( $post, $request ) {
*/
protected function prepare_links( $menu_item ) {
$links = parent::prepare_links( $menu_item );
if ( empty( $menu_item->object_id ) ) {
return $links;
}

if ( 'post_type' === $menu_item->type && ! empty( $menu_item->object_id ) ) {
$post_type_object = get_post_type_object( $menu_item->object );
if ( $post_type_object->show_in_rest ) {
$rest_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name;
$url = rest_url( sprintf( 'wp/v2/%s/%d', $rest_base, $menu_item->object_id ) );
$links['https://api.w.org/object'][] = array(
'href' => $url,
'post_type' => $menu_item->type,
'embeddable' => true,
);
}
} elseif ( 'taxonomy' === $menu_item->type && ! empty( $menu_item->object_id ) ) {
$taxonomy_object = get_taxonomy( $menu_item->object );
if ( $taxonomy_object->show_in_rest ) {
$rest_base = ! empty( $taxonomy_object->rest_base ) ? $taxonomy_object->rest_base : $taxonomy_object->name;
$url = rest_url( sprintf( 'wp/v2/%s/%d', $rest_base, $menu_item->object_id ) );
$links['https://api.w.org/object'][] = array(
'href' => $url,
'taxonomy' => $menu_item->type,
'embeddable' => true,
);
}
$path = '';
if ( 'post_type' === $menu_item->type ) {
$path = rest_get_route_for_post( $menu_item->object_id );
} elseif ( 'taxonomy' === $menu_item->type ) {
$path = rest_get_route_for_term( $menu_item->object_id );
}

if ( $path ) {
$links['https://api.w.org/object'][] = array(
'href' => rest_url( $path ),
'post_type' => $menu_item->type,
'embeddable' => true,
);
}

return $links;
Expand Down
27 changes: 19 additions & 8 deletions lib/class-wp-theme-json-resolver-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,18 @@ public static function get_theme_data( $theme_support_data = array() ) {
$theme_json_data = self::read_json_file( self::get_file_path_from_theme( 'theme.json' ) );
$theme_json_data = self::translate( $theme_json_data, wp_get_theme()->get( 'TextDomain' ) );
self::$theme = new WP_Theme_JSON_Gutenberg( $theme_json_data );

if ( wp_get_theme()->parent() ) {
// Get parent theme.json.
$parent_theme_json_data = self::read_json_file( self::get_file_path_from_theme( 'theme.json', true ) );
$parent_theme_json_data = self::translate( $parent_theme_json_data, wp_get_theme()->parent()->get( 'TextDomain' ) );
$parent_theme = new WP_Theme_JSON_Gutenberg( $parent_theme_json_data );

// Merge the child theme.json into the parent theme.json.
// The child theme takes precedence over the parent.
$parent_theme->merge( self::$theme );
self::$theme = $parent_theme;
}
}

if ( empty( $theme_support_data ) ) {
Expand Down Expand Up @@ -476,7 +488,7 @@ public static function get_user_custom_post_type_id() {
*/
public static function theme_has_support() {
if ( ! isset( self::$theme_has_support ) ) {
self::$theme_has_support = (bool) self::get_file_path_from_theme( 'theme.json' );
self::$theme_has_support = is_readable( get_theme_file_path( 'theme.json' ) );
}

return self::$theme_has_support;
Expand All @@ -490,15 +502,14 @@ public static function theme_has_support() {
* otherwise returns the whole file path.
*
* @param string $file_name Name of the file.
* @param bool $template Use template theme directroy. Default: false.
* @return string The whole file path or empty if the file doesn't exist.
*/
private static function get_file_path_from_theme( $file_name ) {
$located = '';
$candidate = get_theme_file_path( $file_name );
if ( is_readable( $candidate ) ) {
$located = $candidate;
}
return $located;
private static function get_file_path_from_theme( $file_name, $template = false ) {
$path = $template ? get_template_directory() : get_stylesheet_directory();
$candidate = $path . '/' . $file_name;

return is_readable( $candidate ) ? $candidate : '';
}

/**
Expand Down
12 changes: 12 additions & 0 deletions lib/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ function gutenberg_initialize_editor( $editor_name, $editor_script_handle, $sett
'rest_preload_api_request',
array()
);

/**
* Filters the array of data that has been preloaded.
*
* The dynamic portion of the hook name, `$editor_name`, refers to the type of block editor.
*
* @param array $preload_data Array containing the preloaded data.
* @param string $editor_name Current editor name.
* @param array Array containing the filtered preloaded data.
*/
$preload_data = apply_filters( 'block_editor_preload_data', $preload_data, $editor_name );

wp_add_inline_script(
'wp-api-fetch',
sprintf(
Expand Down
105 changes: 102 additions & 3 deletions lib/navigation-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,84 @@ class="edit-navigation"
}

/**
* Initialize the Gutenberg Navigation page.
* This function returns an url for the /__experimental/menus endpoint
*
* @since 7.8.0
* @since 11.8.0
*
* @param int $results_per_page Results per page.
* @return string
*/
function gutenberg_navigation_get_menus_endpoint( $results_per_page = 100 ) {
return '/__experimental/menus?' . build_query(
array(
'per_page' => $results_per_page,
'context' => 'edit',
'_locale' => 'user',
)
);
}

/**
* This function returns an url for the /__experimental/menu-items endpoint
*
* @since 11.8.0
*
* @param int $menu_id Menu ID.
* @param int $results_per_page Results per page.
* @return string
*/
function gutenberg_navigation_get_menu_items_endpoint( $menu_id, $results_per_page = 100 ) {
return '/__experimental/menu-items?' . build_query(
array(
'context' => 'edit',
'menus' => $menu_id,
'per_page' => $results_per_page,
'_locale' => 'user',
)
);
}

/**
* This function returns an url for the /wp/v2/types endpoint
*
* @since 11.8.0
*
* @return string
*/
function gutenberg_navigation_get_types_endpoint() {
return '/wp/v2/types?' . build_query(
array(
'context' => 'edit',
)
);
}

/**
* Initialize the Gutenberg Navigation page.
*
* @param string $hook Page.
* @since 7.8.0
*/
function gutenberg_navigation_init( $hook ) {
if ( 'gutenberg_page_gutenberg-navigation' !== $hook ) {
return;
return;
}

$menus = wp_get_nav_menus();
$first_menu_id = ! empty( $menus ) ? $menus[0]->term_id : null;

$preload_paths = array(
'/__experimental/menu-locations',
array( '/wp/v2/pages', 'OPTIONS' ),
array( '/wp/v2/posts', 'OPTIONS' ),
gutenberg_navigation_get_menus_endpoint(),
gutenberg_navigation_get_types_endpoint(),
);

if ( $first_menu_id ) {
$preload_paths[] = gutenberg_navigation_get_menu_items_endpoint( $first_menu_id );
}

$settings = array_merge(
gutenberg_get_default_block_editor_settings(),
array(
Expand Down Expand Up @@ -82,3 +143,41 @@ function gutenberg_navigation_editor_load_block_editor_scripts_and_styles( $is_b
}

add_filter( 'should_load_block_editor_scripts_and_styles', 'gutenberg_navigation_editor_load_block_editor_scripts_and_styles' );

/**
* This function removes menu-related data from the "common" preloading middleware and calls
* createMenuPreloadingMiddleware middleware because we need to use custom preloading logic for menus.
*
* @param Array $preload_data Array containing the preloaded data.
* @param string $context Current editor name.
* @return array Filtered preload data.
*/
function gutenberg_navigation_editor_preload_menus( $preload_data, $context ) {
if ( 'navigation_editor' !== $context ) {
return $preload_data;
}

$menus_data_path = gutenberg_navigation_get_menus_endpoint();
$menus_data = array();
if ( ! empty( $preload_data[ $menus_data_path ] ) ) {
$menus_data = array( $menus_data_path => $preload_data[ $menus_data_path ] );
}

if ( ! $menus_data ) {
return $preload_data;
}

wp_add_inline_script(
'wp-edit-navigation',
sprintf(
'wp.apiFetch.use( wp.editNavigation.__unstableCreateMenuPreloadingMiddleware( %s ) );',
wp_json_encode( $menus_data )
),
'after'
);

unset( $preload_data[ $menus_data_path ] );
return $preload_data;
}

add_filter( 'block_editor_preload_data', 'gutenberg_navigation_editor_preload_menus', 10, 2 );
Loading

0 comments on commit 57ea53d

Please sign in to comment.