@wordpress/block-library 8.4.0 → 8.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/archives/edit.js +3 -0
- package/build/archives/edit.js.map +1 -1
- package/build/audio/edit.js +2 -0
- package/build/audio/edit.js.map +1 -1
- package/build/avatar/edit.js +5 -9
- package/build/avatar/edit.js.map +1 -1
- package/build/categories/edit.js +5 -0
- package/build/categories/edit.js.map +1 -1
- package/build/columns/edit.js +1 -0
- package/build/columns/edit.js.map +1 -1
- package/build/columns/utils.js +2 -2
- package/build/columns/utils.js.map +1 -1
- package/build/comment-author-name/edit.js +2 -0
- package/build/comment-author-name/edit.js.map +1 -1
- package/build/comment-date/edit.js +1 -0
- package/build/comment-date/edit.js.map +1 -1
- package/build/comment-edit-link/edit.js +1 -0
- package/build/comment-edit-link/edit.js.map +1 -1
- package/build/comments-title/edit.js +2 -0
- package/build/comments-title/edit.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +2 -0
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/embed/embed-controls.js +1 -0
- package/build/embed/embed-controls.js.map +1 -1
- package/build/file/inspector.js +3 -0
- package/build/file/inspector.js.map +1 -1
- package/build/freeform/modal.js +1 -1
- package/build/freeform/modal.js.map +1 -1
- package/build/gallery/edit.js +2 -0
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/shared.js +4 -8
- package/build/gallery/shared.js.map +1 -1
- package/build/gallery/use-image-sizes.js +4 -8
- package/build/gallery/use-image-sizes.js.map +1 -1
- package/build/gallery/v1/edit.js +8 -3
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/gallery/v1/gallery-image.js +1 -3
- package/build/gallery/v1/gallery-image.js.map +1 -1
- package/build/gallery/v1/shared.js +4 -7
- package/build/gallery/v1/shared.js.map +1 -1
- package/build/image/edit.js +6 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +6 -2
- package/build/image/image.js.map +1 -1
- package/build/image/utils.js +3 -1
- package/build/image/utils.js.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/latest-comments/edit.js +3 -0
- package/build/latest-comments/edit.js.map +1 -1
- package/build/latest-posts/edit.js +4 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/list/ordered-list-settings.js +1 -0
- package/build/list/ordered-list-settings.js.map +1 -1
- package/build/list-item/edit.js +2 -2
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +2 -1
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/loginout/edit.js +2 -0
- package/build/loginout/edit.js.map +1 -1
- package/build/media-text/edit.js +2 -0
- package/build/media-text/edit.js.map +1 -1
- package/build/more/edit.js +1 -0
- package/build/more/edit.js.map +1 -1
- package/build/navigation/edit/index.js +80 -54
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +1 -1
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/overlay-menu-preview.js +1 -0
- package/build/navigation/edit/overlay-menu-preview.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +1 -1
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +1 -1
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build/navigation/edit/use-generate-default-navigation-title.js +1 -1
- package/build/navigation/edit/use-generate-default-navigation-title.js.map +1 -1
- package/build/navigation/edit/use-navigation-notice.js +4 -7
- package/build/navigation/edit/use-navigation-notice.js.map +1 -1
- package/build/navigation-link/link-ui.js +1 -0
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +47 -0
- package/build/page-list/convert-to-links-modal.js.map +1 -0
- package/build/page-list/edit.js +10 -24
- package/build/page-list/edit.js.map +1 -1
- package/build/paragraph/edit.js +1 -0
- package/build/paragraph/edit.js.map +1 -1
- package/build/post-author/edit.js +4 -0
- package/build/post-author/edit.js.map +1 -1
- package/build/post-author-name/edit.js +2 -0
- package/build/post-author-name/edit.js.map +1 -1
- package/build/post-date/edit.js +2 -0
- package/build/post-date/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +1 -0
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +2 -0
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-navigation-link/edit.js +2 -0
- package/build/post-navigation-link/edit.js.map +1 -1
- package/build/post-terms/use-post-terms.js +1 -1
- package/build/post-terms/use-post-terms.js.map +1 -1
- package/build/post-time-to-read/edit.js +104 -0
- package/build/post-time-to-read/edit.js.map +1 -0
- package/build/post-time-to-read/icon.js +25 -0
- package/build/post-time-to-read/icon.js.map +1 -0
- package/build/post-time-to-read/index.js +57 -0
- package/build/post-time-to-read/index.js.map +1 -0
- package/build/post-title/edit.js +2 -0
- package/build/post-title/edit.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +1 -0
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query-title/edit.js +2 -0
- package/build/query-title/edit.js.map +1 -1
- package/build/read-more/edit.js +1 -0
- package/build/read-more/edit.js.map +1 -1
- package/build/rss/edit.js +3 -0
- package/build/rss/edit.js.map +1 -1
- package/build/site-logo/edit.js +3 -0
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-tagline/index.js +1 -0
- package/build/site-tagline/index.js.map +1 -1
- package/build/site-title/edit/index.js +2 -0
- package/build/site-title/edit/index.js.map +1 -1
- package/build/social-links/edit.js +4 -1
- package/build/social-links/edit.js.map +1 -1
- package/build/spacer/controls.native.js +10 -8
- package/build/spacer/controls.native.js.map +1 -1
- package/build/spacer/edit.native.js +43 -5
- package/build/spacer/edit.native.js.map +1 -1
- package/build/spacer/save.native.js +30 -0
- package/build/spacer/save.native.js.map +1 -0
- package/build/table/edit.js +3 -0
- package/build/table/edit.js.map +1 -1
- package/build/table-of-contents/edit.js +1 -0
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/tag-cloud/edit.js +1 -0
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/template-part/edit/import-controls.js +29 -6
- package/build/template-part/edit/import-controls.js.map +1 -1
- package/build/video/edit-common-settings.js +5 -0
- package/build/video/edit-common-settings.js.map +1 -1
- package/build-module/archives/edit.js +3 -0
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/audio/edit.js +2 -0
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/avatar/edit.js +5 -8
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/categories/edit.js +5 -0
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/columns/edit.js +1 -0
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/columns/utils.js +3 -3
- package/build-module/columns/utils.js.map +1 -1
- package/build-module/comment-author-name/edit.js +2 -0
- package/build-module/comment-author-name/edit.js.map +1 -1
- package/build-module/comment-date/edit.js +1 -0
- package/build-module/comment-date/edit.js.map +1 -1
- package/build-module/comment-edit-link/edit.js +1 -0
- package/build-module/comment-edit-link/edit.js.map +1 -1
- package/build-module/comments-title/edit.js +2 -0
- package/build-module/comments-title/edit.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +2 -0
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/embed/embed-controls.js +1 -0
- package/build-module/embed/embed-controls.js.map +1 -1
- package/build-module/file/inspector.js +3 -0
- package/build-module/file/inspector.js.map +1 -1
- package/build-module/freeform/modal.js +1 -1
- package/build-module/freeform/modal.js.map +1 -1
- package/build-module/gallery/edit.js +2 -0
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/shared.js +4 -7
- package/build-module/gallery/shared.js.map +1 -1
- package/build-module/gallery/use-image-sizes.js +4 -7
- package/build-module/gallery/use-image-sizes.js.map +1 -1
- package/build-module/gallery/v1/edit.js +9 -4
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/gallery/v1/gallery-image.js +1 -2
- package/build-module/gallery/v1/gallery-image.js.map +1 -1
- package/build-module/gallery/v1/shared.js +4 -6
- package/build-module/gallery/v1/shared.js.map +1 -1
- package/build-module/image/edit.js +7 -5
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +7 -3
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/utils.js +4 -2
- package/build-module/image/utils.js.map +1 -1
- package/build-module/index.js +2 -1
- package/build-module/index.js.map +1 -1
- package/build-module/latest-comments/edit.js +3 -0
- package/build-module/latest-comments/edit.js.map +1 -1
- package/build-module/latest-posts/edit.js +4 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/list/ordered-list-settings.js +1 -0
- package/build-module/list/ordered-list-settings.js.map +1 -1
- package/build-module/list-item/edit.js +2 -2
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +2 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/loginout/edit.js +2 -0
- package/build-module/loginout/edit.js.map +1 -1
- package/build-module/media-text/edit.js +2 -0
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/more/edit.js +1 -0
- package/build-module/more/edit.js.map +1 -1
- package/build-module/navigation/edit/index.js +82 -56
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/overlay-menu-preview.js +1 -0
- package/build-module/navigation/edit/overlay-menu-preview.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +1 -1
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +1 -1
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build-module/navigation/edit/use-generate-default-navigation-title.js +1 -1
- package/build-module/navigation/edit/use-generate-default-navigation-title.js.map +1 -1
- package/build-module/navigation/edit/use-navigation-notice.js +5 -8
- package/build-module/navigation/edit/use-navigation-notice.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +1 -0
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +35 -0
- package/build-module/page-list/convert-to-links-modal.js.map +1 -0
- package/build-module/page-list/edit.js +10 -25
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/paragraph/edit.js +1 -0
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/post-author/edit.js +4 -0
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-author-name/edit.js +2 -0
- package/build-module/post-author-name/edit.js.map +1 -1
- package/build-module/post-date/edit.js +2 -0
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +1 -0
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +2 -0
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-navigation-link/edit.js +2 -0
- package/build-module/post-navigation-link/edit.js.map +1 -1
- package/build-module/post-terms/use-post-terms.js +1 -1
- package/build-module/post-terms/use-post-terms.js.map +1 -1
- package/build-module/post-time-to-read/edit.js +90 -0
- package/build-module/post-time-to-read/edit.js.map +1 -0
- package/build-module/post-time-to-read/icon.js +15 -0
- package/build-module/post-time-to-read/icon.js.map +1 -0
- package/build-module/post-time-to-read/index.js +40 -0
- package/build-module/post-time-to-read/index.js.map +1 -0
- package/build-module/post-title/edit.js +2 -0
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +1 -0
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query-title/edit.js +2 -0
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/read-more/edit.js +1 -0
- package/build-module/read-more/edit.js.map +1 -1
- package/build-module/rss/edit.js +3 -0
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +3 -0
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-tagline/index.js +1 -0
- package/build-module/site-tagline/index.js.map +1 -1
- package/build-module/site-title/edit/index.js +2 -0
- package/build-module/site-title/edit/index.js.map +1 -1
- package/build-module/social-links/edit.js +4 -1
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/spacer/controls.native.js +9 -8
- package/build-module/spacer/controls.native.js.map +1 -1
- package/build-module/spacer/edit.native.js +39 -7
- package/build-module/spacer/edit.native.js.map +1 -1
- package/build-module/spacer/save.native.js +22 -0
- package/build-module/spacer/save.native.js.map +1 -0
- package/build-module/table/edit.js +3 -0
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js +1 -0
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/tag-cloud/edit.js +1 -0
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/template-part/edit/import-controls.js +28 -6
- package/build-module/template-part/edit/import-controls.js.map +1 -1
- package/build-module/video/edit-common-settings.js +5 -0
- package/build-module/video/edit-common-settings.js.map +1 -1
- package/build-style/editor-rtl.css +4 -3
- package/build-style/editor.css +4 -3
- package/build-style/post-excerpt/editor-rtl.css +1 -1
- package/build-style/post-excerpt/editor.css +1 -1
- package/build-style/query/editor-rtl.css +1 -0
- package/build-style/query/editor.css +1 -0
- package/build-style/site-logo/editor-rtl.css +2 -2
- package/build-style/site-logo/editor.css +2 -2
- package/package.json +31 -30
- package/src/archives/edit.js +3 -0
- package/src/audio/edit.js +2 -0
- package/src/audio/test/__snapshots__/edit.native.js.snap +38 -38
- package/src/avatar/edit.js +2 -4
- package/src/buttons/test/__snapshots__/edit.native.js.snap +11 -11
- package/src/categories/edit.js +5 -0
- package/src/code/test/__snapshots__/edit.native.js.snap +2 -2
- package/src/columns/edit.js +1 -0
- package/src/columns/test/__snapshots__/edit.native.js.snap +66 -66
- package/src/columns/test/utils.js +54 -0
- package/src/columns/utils.js +8 -8
- package/src/comment-author-name/edit.js +2 -0
- package/src/comment-date/edit.js +1 -0
- package/src/comment-edit-link/edit.js +1 -0
- package/src/comments-title/edit.js +2 -0
- package/src/cover/edit/inspector-controls.js +2 -0
- package/src/cover/index.php +4 -6
- package/src/cover/test/__snapshots__/edit.native.js.snap +36 -36
- package/src/embed/embed-controls.js +1 -0
- package/src/embed/test/__snapshots__/index.native.js.snap +52 -52
- package/src/file/inspector.js +3 -0
- package/src/file/test/__snapshots__/edit.native.js.snap +49 -49
- package/src/freeform/modal.js +1 -1
- package/src/gallery/edit.js +2 -0
- package/src/gallery/shared.js +6 -11
- package/src/gallery/test/__snapshots__/index.native.js.snap +71 -71
- package/src/gallery/use-image-sizes.js +3 -16
- package/src/gallery/v1/edit.js +8 -16
- package/src/gallery/v1/gallery-image.js +1 -2
- package/src/gallery/v1/shared.js +5 -10
- package/src/group/test/__snapshots__/edit.native.js.snap +5 -5
- package/src/heading/test/__snapshots__/index.native.js.snap +1 -1
- package/src/image/edit.js +4 -4
- package/src/image/image.js +4 -9
- package/src/image/index.php +4 -4
- package/src/image/utils.js +2 -2
- package/src/index.js +2 -0
- package/src/latest-comments/edit.js +3 -0
- package/src/latest-posts/edit.js +4 -0
- package/src/list/ordered-list-settings.js +1 -0
- package/src/list/test/__snapshots__/edit.native.js.snap +4 -4
- package/src/list-item/edit.js +10 -3
- package/src/list-item/hooks/use-outdent-list-item.js +2 -1
- package/src/loginout/edit.js +2 -0
- package/src/media-text/edit.js +2 -0
- package/src/missing/test/__snapshots__/edit.native.js.snap +1 -1
- package/src/more/edit.js +1 -0
- package/src/navigation/edit/index.js +130 -82
- package/src/navigation/edit/navigation-menu-selector.js +1 -1
- package/src/navigation/edit/overlay-menu-preview.js +1 -0
- package/src/navigation/edit/placeholder/index.js +1 -1
- package/src/navigation/edit/unsaved-inner-blocks.js +1 -0
- package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +51 -48
- package/src/navigation/edit/use-create-navigation-menu.js +1 -1
- package/src/navigation/edit/use-generate-default-navigation-title.js +1 -1
- package/src/navigation/edit/use-navigation-notice.js +16 -13
- package/src/navigation/index.php +42 -19
- package/src/navigation-link/link-ui.js +1 -0
- package/src/navigation-link/test/__snapshots__/hooks.js.snap +12 -12
- package/src/page-list/convert-to-links-modal.js +38 -0
- package/src/page-list/edit.js +11 -32
- package/src/paragraph/edit.js +1 -0
- package/src/post-author/edit.js +4 -0
- package/src/post-author-name/edit.js +2 -0
- package/src/post-date/edit.js +2 -0
- package/src/post-excerpt/edit.js +1 -0
- package/src/post-excerpt/editor.scss +1 -1
- package/src/post-featured-image/edit.js +2 -0
- package/src/post-navigation-link/edit.js +2 -0
- package/src/post-terms/index.php +1 -0
- package/src/post-terms/use-post-terms.js +1 -1
- package/src/post-time-to-read/block.json +20 -0
- package/src/post-time-to-read/edit.js +101 -0
- package/src/post-time-to-read/icon.js +15 -0
- package/src/post-time-to-read/index.js +17 -0
- package/src/post-time-to-read/index.php +62 -0
- package/src/post-title/edit.js +2 -0
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +10 -10
- package/src/query/edit/inspector-controls/index.js +1 -0
- package/src/query/editor.scss +1 -0
- package/src/query-title/edit.js +2 -0
- package/src/read-more/edit.js +1 -0
- package/src/rss/edit.js +3 -0
- package/src/search/test/__snapshots__/edit.native.js.snap +60 -60
- package/src/separator/test/__snapshots__/edit.native.js.snap +1 -1
- package/src/site-logo/edit.js +3 -0
- package/src/site-logo/editor.scss +3 -3
- package/src/site-logo/index.php +7 -2
- package/src/site-tagline/block.json +1 -0
- package/src/site-title/edit/index.js +2 -0
- package/src/social-link/index.php +6 -6
- package/src/social-links/edit.js +3 -0
- package/src/social-links/test/__snapshots__/edit.native.js.snap +16 -16
- package/src/spacer/controls.native.js +13 -5
- package/src/spacer/edit.native.js +45 -6
- package/src/spacer/save.native.js +18 -0
- package/src/spacer/test/__snapshots__/index.native.js.snap +21 -9
- package/src/spacer/test/index.native.js +81 -0
- package/src/table/edit.js +3 -0
- package/src/table-of-contents/edit.js +1 -0
- package/src/tag-cloud/edit.js +1 -0
- package/src/template-part/edit/import-controls.js +24 -5
- package/src/template-part/index.php +7 -6
- package/src/verse/test/__snapshots__/edit.native.js.snap +2 -2
- package/src/video/edit-common-settings.js +5 -0
- package/tsconfig.json +2 -1
- package/tsconfig.tsbuildinfo +1 -1
package/src/navigation/index.php
CHANGED
|
@@ -431,6 +431,37 @@ function block_core_navigation_block_contains_core_navigation( $inner_blocks ) {
|
|
|
431
431
|
return false;
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
+
/**
|
|
435
|
+
* Create and returns a navigation menu containing a page-list as a fallback.
|
|
436
|
+
*
|
|
437
|
+
* @return array the newly created navigation menu.
|
|
438
|
+
*/
|
|
439
|
+
function block_core_navigation_get_default_pages_fallback() {
|
|
440
|
+
$registry = WP_Block_Type_Registry::get_instance();
|
|
441
|
+
|
|
442
|
+
// If `core/page-list` is not registered then use empty blocks.
|
|
443
|
+
$default_blocks = $registry->is_registered( 'core/page-list' ) ? '<!-- wp:page-list /-->' : '';
|
|
444
|
+
|
|
445
|
+
// Create a new navigation menu from the fallback blocks.
|
|
446
|
+
$wp_insert_post_result = wp_insert_post(
|
|
447
|
+
array(
|
|
448
|
+
'post_content' => $default_blocks,
|
|
449
|
+
'post_title' => 'Navigation', // TODO - use the template slug in future.
|
|
450
|
+
'post_name' => 'Navigation', // TODO - use the template slug in future.
|
|
451
|
+
'post_status' => 'publish',
|
|
452
|
+
'post_type' => 'wp_navigation',
|
|
453
|
+
),
|
|
454
|
+
true // So that we can check whether the result is an error.
|
|
455
|
+
);
|
|
456
|
+
|
|
457
|
+
if ( is_wp_error( $wp_insert_post_result ) ) {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// Fetch the most recently published navigation which will be the default one created above.
|
|
462
|
+
return block_core_navigation_get_most_recently_published_navigation();
|
|
463
|
+
}
|
|
464
|
+
|
|
434
465
|
/**
|
|
435
466
|
* Retrieves the appropriate fallback to be used on the front of the
|
|
436
467
|
* site when there is no menu assigned to the Nav block.
|
|
@@ -441,19 +472,7 @@ function block_core_navigation_block_contains_core_navigation( $inner_blocks ) {
|
|
|
441
472
|
* @return array the array of blocks to be used as a fallback.
|
|
442
473
|
*/
|
|
443
474
|
function block_core_navigation_get_fallback_blocks() {
|
|
444
|
-
|
|
445
|
-
array(
|
|
446
|
-
'blockName' => 'core/page-list',
|
|
447
|
-
),
|
|
448
|
-
);
|
|
449
|
-
|
|
450
|
-
$registry = WP_Block_Type_Registry::get_instance();
|
|
451
|
-
|
|
452
|
-
// If `core/page-list` is not registered then return empty blocks.
|
|
453
|
-
$fallback_blocks = $registry->is_registered( 'core/page-list' ) ? $page_list_fallback : array();
|
|
454
|
-
|
|
455
|
-
// Default to a list of Pages.
|
|
456
|
-
|
|
475
|
+
// Get the most recently published Navigation post.
|
|
457
476
|
$navigation_post = block_core_navigation_get_most_recently_published_navigation();
|
|
458
477
|
|
|
459
478
|
// If there are no navigation posts then try to find a classic menu
|
|
@@ -462,16 +481,21 @@ function block_core_navigation_get_fallback_blocks() {
|
|
|
462
481
|
$navigation_post = block_core_navigation_maybe_use_classic_menu_fallback();
|
|
463
482
|
}
|
|
464
483
|
|
|
465
|
-
//
|
|
484
|
+
// If there are no navigation posts then default to a list of Pages.
|
|
485
|
+
if ( ! $navigation_post ) {
|
|
486
|
+
$navigation_post = block_core_navigation_get_default_pages_fallback();
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// Use the first non-empty Navigation as fallback, there should always be one.
|
|
466
490
|
if ( $navigation_post ) {
|
|
467
491
|
$parsed_blocks = parse_blocks( $navigation_post->post_content );
|
|
468
492
|
$maybe_fallback = block_core_navigation_filter_out_empty_blocks( $parsed_blocks );
|
|
469
|
-
|
|
470
|
-
// Normalizing blocks may result in an empty array of blocks if they were all `null` blocks.
|
|
471
|
-
// In this case default to the (Page List) fallback.
|
|
472
|
-
$fallback_blocks = ! empty( $maybe_fallback ) ? $maybe_fallback : $fallback_blocks;
|
|
473
493
|
}
|
|
474
494
|
|
|
495
|
+
// Normalizing blocks may result in an empty array of blocks if they were all `null` blocks.
|
|
496
|
+
// In this case default empty blocks.
|
|
497
|
+
$fallback_blocks = ! empty( $maybe_fallback ) ? $maybe_fallback : array();
|
|
498
|
+
|
|
475
499
|
/**
|
|
476
500
|
* Filters the fallback experience for the Navigation block.
|
|
477
501
|
*
|
|
@@ -531,7 +555,6 @@ function block_core_navigation_from_block_get_post_ids( $block ) {
|
|
|
531
555
|
* @return string Returns the post content with the legacy widget added.
|
|
532
556
|
*/
|
|
533
557
|
function render_block_core_navigation( $attributes, $content, $block ) {
|
|
534
|
-
|
|
535
558
|
static $seen_menu_names = array();
|
|
536
559
|
|
|
537
560
|
// Flag used to indicate whether the rendered output is considered to be
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`hooks enhanceNavigationLinkVariations enhances variations with icon and isActive functions 1`] = `
|
|
4
|
-
|
|
4
|
+
{
|
|
5
5
|
"extraProp": "extraProp",
|
|
6
6
|
"name": "core/navigation-link",
|
|
7
|
-
"variations":
|
|
8
|
-
|
|
9
|
-
"attributes":
|
|
7
|
+
"variations": [
|
|
8
|
+
{
|
|
9
|
+
"attributes": {},
|
|
10
10
|
"description": "A link to a custom URL.",
|
|
11
11
|
"icon": <SVG
|
|
12
12
|
viewBox="0 0 24 24"
|
|
@@ -20,8 +20,8 @@ Object {
|
|
|
20
20
|
"name": "link",
|
|
21
21
|
"title": "Custom Link",
|
|
22
22
|
},
|
|
23
|
-
|
|
24
|
-
"attributes":
|
|
23
|
+
{
|
|
24
|
+
"attributes": {
|
|
25
25
|
"type": "post",
|
|
26
26
|
},
|
|
27
27
|
"description": "A link to a post.",
|
|
@@ -37,8 +37,8 @@ Object {
|
|
|
37
37
|
"name": "post",
|
|
38
38
|
"title": "Post Link",
|
|
39
39
|
},
|
|
40
|
-
|
|
41
|
-
"attributes":
|
|
40
|
+
{
|
|
41
|
+
"attributes": {
|
|
42
42
|
"type": "page",
|
|
43
43
|
},
|
|
44
44
|
"description": "A link to a page.",
|
|
@@ -54,8 +54,8 @@ Object {
|
|
|
54
54
|
"name": "page",
|
|
55
55
|
"title": "Page Link",
|
|
56
56
|
},
|
|
57
|
-
|
|
58
|
-
"attributes":
|
|
57
|
+
{
|
|
58
|
+
"attributes": {
|
|
59
59
|
"type": "category",
|
|
60
60
|
},
|
|
61
61
|
"description": "A link to a category.",
|
|
@@ -73,8 +73,8 @@ Object {
|
|
|
73
73
|
"name": "category",
|
|
74
74
|
"title": "Category Link",
|
|
75
75
|
},
|
|
76
|
-
|
|
77
|
-
"attributes":
|
|
76
|
+
{
|
|
77
|
+
"attributes": {
|
|
78
78
|
"type": "tag",
|
|
79
79
|
},
|
|
80
80
|
"description": "A link to a tag.",
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Button, Modal } from '@wordpress/components';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
export const convertDescription = __(
|
|
8
|
+
'This menu is automatically kept in sync with pages on your site. You can manage the menu yourself by clicking "Edit" below.'
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export function ConvertToLinksModal( { onClick, onClose, disabled } ) {
|
|
12
|
+
return (
|
|
13
|
+
<Modal
|
|
14
|
+
onRequestClose={ onClose }
|
|
15
|
+
title={ __( 'Edit this menu' ) }
|
|
16
|
+
className={ 'wp-block-page-list-modal' }
|
|
17
|
+
aria={ {
|
|
18
|
+
describedby: 'wp-block-page-list-modal__description',
|
|
19
|
+
} }
|
|
20
|
+
>
|
|
21
|
+
<p id={ 'wp-block-page-list-modal__description' }>
|
|
22
|
+
{ convertDescription }
|
|
23
|
+
</p>
|
|
24
|
+
<div className="wp-block-page-list-modal-buttons">
|
|
25
|
+
<Button variant="tertiary" onClick={ onClose }>
|
|
26
|
+
{ __( 'Cancel' ) }
|
|
27
|
+
</Button>
|
|
28
|
+
<Button
|
|
29
|
+
variant="primary"
|
|
30
|
+
disabled={ disabled }
|
|
31
|
+
onClick={ onClick }
|
|
32
|
+
>
|
|
33
|
+
{ __( 'Edit' ) }
|
|
34
|
+
</Button>
|
|
35
|
+
</div>
|
|
36
|
+
</Modal>
|
|
37
|
+
);
|
|
38
|
+
}
|
package/src/page-list/edit.js
CHANGED
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
Notice,
|
|
24
24
|
ComboboxControl,
|
|
25
25
|
Button,
|
|
26
|
-
Modal,
|
|
27
26
|
} from '@wordpress/components';
|
|
28
27
|
import { __, sprintf } from '@wordpress/i18n';
|
|
29
28
|
import { useMemo, useState, useEffect } from '@wordpress/element';
|
|
@@ -34,16 +33,15 @@ import { useSelect } from '@wordpress/data';
|
|
|
34
33
|
* Internal dependencies
|
|
35
34
|
*/
|
|
36
35
|
import { useConvertToNavigationLinks } from './use-convert-to-navigation-links';
|
|
36
|
+
import {
|
|
37
|
+
convertDescription,
|
|
38
|
+
ConvertToLinksModal,
|
|
39
|
+
} from './convert-to-links-modal';
|
|
37
40
|
|
|
38
41
|
// We only show the edit option when page count is <= MAX_PAGE_COUNT
|
|
39
42
|
// Performance of Navigation Links is not good past this value.
|
|
40
43
|
const MAX_PAGE_COUNT = 100;
|
|
41
44
|
const NOOP = () => {};
|
|
42
|
-
|
|
43
|
-
const convertDescription = __(
|
|
44
|
-
'This menu is automatically kept in sync with pages on your site. You can manage the menu yourself by clicking "Edit" below.'
|
|
45
|
-
);
|
|
46
|
-
|
|
47
45
|
function BlockContent( {
|
|
48
46
|
blockProps,
|
|
49
47
|
innerBlocksProps,
|
|
@@ -113,7 +111,7 @@ function BlockContent( {
|
|
|
113
111
|
}
|
|
114
112
|
}
|
|
115
113
|
|
|
116
|
-
function
|
|
114
|
+
function ConvertToLinks( { onClick, disabled } ) {
|
|
117
115
|
const [ isOpen, setOpen ] = useState( false );
|
|
118
116
|
const openModal = () => setOpen( true );
|
|
119
117
|
const closeModal = () => setOpen( false );
|
|
@@ -126,30 +124,11 @@ function ConvertToLinksModal( { onClick, disabled } ) {
|
|
|
126
124
|
</ToolbarButton>
|
|
127
125
|
</BlockControls>
|
|
128
126
|
{ isOpen && (
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
describedby: 'wp-block-page-list-modal__description',
|
|
135
|
-
} }
|
|
136
|
-
>
|
|
137
|
-
<p id={ 'wp-block-page-list-modal__description' }>
|
|
138
|
-
{ convertDescription }
|
|
139
|
-
</p>
|
|
140
|
-
<div className="wp-block-page-list-modal-buttons">
|
|
141
|
-
<Button variant="tertiary" onClick={ closeModal }>
|
|
142
|
-
{ __( 'Cancel' ) }
|
|
143
|
-
</Button>
|
|
144
|
-
<Button
|
|
145
|
-
variant="primary"
|
|
146
|
-
disabled={ disabled }
|
|
147
|
-
onClick={ onClick }
|
|
148
|
-
>
|
|
149
|
-
{ __( 'Edit' ) }
|
|
150
|
-
</Button>
|
|
151
|
-
</div>
|
|
152
|
-
</Modal>
|
|
127
|
+
<ConvertToLinksModal
|
|
128
|
+
onClick={ onClick }
|
|
129
|
+
onClose={ closeModal }
|
|
130
|
+
disabled={ disabled }
|
|
131
|
+
/>
|
|
153
132
|
) }
|
|
154
133
|
</>
|
|
155
134
|
);
|
|
@@ -344,7 +323,7 @@ export default function PageListEdit( {
|
|
|
344
323
|
) }
|
|
345
324
|
</InspectorControls>
|
|
346
325
|
{ allowConvertToLinks && (
|
|
347
|
-
<
|
|
326
|
+
<ConvertToLinks
|
|
348
327
|
disabled={ ! hasResolvedPages }
|
|
349
328
|
onClick={ convertToNavigationLinks }
|
|
350
329
|
/>
|
package/src/paragraph/edit.js
CHANGED
package/src/post-author/edit.js
CHANGED
|
@@ -120,6 +120,7 @@ function PostAuthorEdit( {
|
|
|
120
120
|
/>
|
|
121
121
|
) ) }
|
|
122
122
|
<ToggleControl
|
|
123
|
+
__nextHasNoMarginBottom
|
|
123
124
|
label={ __( 'Show avatar' ) }
|
|
124
125
|
checked={ showAvatar }
|
|
125
126
|
onChange={ () =>
|
|
@@ -140,6 +141,7 @@ function PostAuthorEdit( {
|
|
|
140
141
|
/>
|
|
141
142
|
) }
|
|
142
143
|
<ToggleControl
|
|
144
|
+
__nextHasNoMarginBottom
|
|
143
145
|
label={ __( 'Show bio' ) }
|
|
144
146
|
checked={ showBio }
|
|
145
147
|
onChange={ () =>
|
|
@@ -147,12 +149,14 @@ function PostAuthorEdit( {
|
|
|
147
149
|
}
|
|
148
150
|
/>
|
|
149
151
|
<ToggleControl
|
|
152
|
+
__nextHasNoMarginBottom
|
|
150
153
|
label={ __( 'Link author name to author page' ) }
|
|
151
154
|
checked={ isLink }
|
|
152
155
|
onChange={ () => setAttributes( { isLink: ! isLink } ) }
|
|
153
156
|
/>
|
|
154
157
|
{ isLink && (
|
|
155
158
|
<ToggleControl
|
|
159
|
+
__nextHasNoMarginBottom
|
|
156
160
|
label={ __( 'Open in new tab' ) }
|
|
157
161
|
onChange={ ( value ) =>
|
|
158
162
|
setAttributes( {
|
|
@@ -71,12 +71,14 @@ function PostAuthorNameEdit( {
|
|
|
71
71
|
<InspectorControls>
|
|
72
72
|
<PanelBody title={ __( 'Link settings' ) }>
|
|
73
73
|
<ToggleControl
|
|
74
|
+
__nextHasNoMarginBottom
|
|
74
75
|
label={ __( 'Link to author archive' ) }
|
|
75
76
|
onChange={ () => setAttributes( { isLink: ! isLink } ) }
|
|
76
77
|
checked={ isLink }
|
|
77
78
|
/>
|
|
78
79
|
{ isLink && (
|
|
79
80
|
<ToggleControl
|
|
81
|
+
__nextHasNoMarginBottom
|
|
80
82
|
label={ __( 'Open in new tab' ) }
|
|
81
83
|
onChange={ ( value ) =>
|
|
82
84
|
setAttributes( {
|
package/src/post-date/edit.js
CHANGED
|
@@ -150,6 +150,7 @@ export default function PostDateEdit( {
|
|
|
150
150
|
}
|
|
151
151
|
/>
|
|
152
152
|
<ToggleControl
|
|
153
|
+
__nextHasNoMarginBottom
|
|
153
154
|
label={
|
|
154
155
|
postType?.labels.singular_name
|
|
155
156
|
? sprintf(
|
|
@@ -163,6 +164,7 @@ export default function PostDateEdit( {
|
|
|
163
164
|
checked={ isLink }
|
|
164
165
|
/>
|
|
165
166
|
<ToggleControl
|
|
167
|
+
__nextHasNoMarginBottom
|
|
166
168
|
label={ __( 'Display last modified date' ) }
|
|
167
169
|
onChange={ ( value ) =>
|
|
168
170
|
setAttributes( {
|
package/src/post-excerpt/edit.js
CHANGED
|
@@ -194,6 +194,7 @@ export default function PostExcerptEditor( {
|
|
|
194
194
|
<InspectorControls>
|
|
195
195
|
<PanelBody title={ __( 'Settings' ) }>
|
|
196
196
|
<ToggleControl
|
|
197
|
+
__nextHasNoMarginBottom
|
|
197
198
|
label={ __( 'Show link on new line' ) }
|
|
198
199
|
checked={ showMoreOnNewLine }
|
|
199
200
|
onChange={ ( newShowMoreOnNewLine ) =>
|
|
@@ -141,6 +141,7 @@ export default function PostFeaturedImageEdit( {
|
|
|
141
141
|
<InspectorControls>
|
|
142
142
|
<PanelBody title={ __( 'Link settings' ) }>
|
|
143
143
|
<ToggleControl
|
|
144
|
+
__nextHasNoMarginBottom
|
|
144
145
|
label={
|
|
145
146
|
postType?.labels.singular_name
|
|
146
147
|
? sprintf(
|
|
@@ -156,6 +157,7 @@ export default function PostFeaturedImageEdit( {
|
|
|
156
157
|
{ isLink && (
|
|
157
158
|
<>
|
|
158
159
|
<ToggleControl
|
|
160
|
+
__nextHasNoMarginBottom
|
|
159
161
|
label={ __( 'Open in new tab' ) }
|
|
160
162
|
onChange={ ( value ) =>
|
|
161
163
|
setAttributes( {
|
|
@@ -52,6 +52,7 @@ export default function PostNavigationLinkEdit( {
|
|
|
52
52
|
<InspectorControls>
|
|
53
53
|
<PanelBody>
|
|
54
54
|
<ToggleControl
|
|
55
|
+
__nextHasNoMarginBottom
|
|
55
56
|
label={ __( 'Display the title as a link' ) }
|
|
56
57
|
help={ __(
|
|
57
58
|
'If you have entered a custom label, it will be prepended before the title.'
|
|
@@ -65,6 +66,7 @@ export default function PostNavigationLinkEdit( {
|
|
|
65
66
|
/>
|
|
66
67
|
{ showTitle && (
|
|
67
68
|
<ToggleControl
|
|
69
|
+
__nextHasNoMarginBottom
|
|
68
70
|
label={ __(
|
|
69
71
|
'Include the label as part of the link'
|
|
70
72
|
) }
|
package/src/post-terms/index.php
CHANGED
|
@@ -87,6 +87,7 @@ function register_block_core_post_terms() {
|
|
|
87
87
|
'term' => $taxonomy->name,
|
|
88
88
|
),
|
|
89
89
|
'isActive' => array( 'term' ),
|
|
90
|
+
'scope' => array( 'inserter', 'transform' ),
|
|
90
91
|
);
|
|
91
92
|
// Set the category variation as the default one.
|
|
92
93
|
if ( 'category' === $taxonomy->name ) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 2,
|
|
4
|
+
"__experimental": true,
|
|
5
|
+
"name": "core/post-time-to-read",
|
|
6
|
+
"title": "Time To Read",
|
|
7
|
+
"category": "theme",
|
|
8
|
+
"description": "Show minutes required to finish reading the post.",
|
|
9
|
+
"textdomain": "default",
|
|
10
|
+
"usesContext": [ "postId", "postType" ],
|
|
11
|
+
"attributes": {
|
|
12
|
+
"textAlign": {
|
|
13
|
+
"type": "string"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"supports": {
|
|
17
|
+
"html": false,
|
|
18
|
+
"multiple": false
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { _x, _n, sprintf } from '@wordpress/i18n';
|
|
10
|
+
import { useMemo } from '@wordpress/element';
|
|
11
|
+
import {
|
|
12
|
+
AlignmentControl,
|
|
13
|
+
BlockControls,
|
|
14
|
+
useBlockProps,
|
|
15
|
+
} from '@wordpress/block-editor';
|
|
16
|
+
import { __unstableSerializeAndClean } from '@wordpress/blocks';
|
|
17
|
+
import { useEntityProp, useEntityBlockEditor } from '@wordpress/core-data';
|
|
18
|
+
import { count as wordCount } from '@wordpress/wordcount';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Average reading rate - based on average taken from
|
|
22
|
+
* https://irisreading.com/average-reading-speed-in-various-languages/
|
|
23
|
+
* (Characters/minute used for Chinese rather than words).
|
|
24
|
+
*/
|
|
25
|
+
const AVERAGE_READING_RATE = 189;
|
|
26
|
+
|
|
27
|
+
function PostTimeToReadEdit( { attributes, setAttributes, context } ) {
|
|
28
|
+
const { textAlign } = attributes;
|
|
29
|
+
const { postId, postType } = context;
|
|
30
|
+
|
|
31
|
+
const [ contentStructure ] = useEntityProp(
|
|
32
|
+
'postType',
|
|
33
|
+
postType,
|
|
34
|
+
'content',
|
|
35
|
+
postId
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const [ blocks ] = useEntityBlockEditor( 'postType', postType, {
|
|
39
|
+
id: postId,
|
|
40
|
+
} );
|
|
41
|
+
|
|
42
|
+
const minutesToReadString = useMemo( () => {
|
|
43
|
+
// Replicates the logic found in getEditedPostContent().
|
|
44
|
+
let content;
|
|
45
|
+
if ( contentStructure instanceof Function ) {
|
|
46
|
+
content = contentStructure( { blocks } );
|
|
47
|
+
} else if ( blocks ) {
|
|
48
|
+
// If we have parsed blocks already, they should be our source of truth.
|
|
49
|
+
// Parsing applies block deprecations and legacy block conversions that
|
|
50
|
+
// unparsed content will not have.
|
|
51
|
+
content = __unstableSerializeAndClean( blocks );
|
|
52
|
+
} else {
|
|
53
|
+
content = contentStructure;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
* translators: If your word count is based on single characters (e.g. East Asian characters),
|
|
58
|
+
* enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
|
|
59
|
+
* Do not translate into your own language.
|
|
60
|
+
*/
|
|
61
|
+
const wordCountType = _x(
|
|
62
|
+
'words',
|
|
63
|
+
'Word count type. Do not translate!'
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const minutesToRead = Math.max(
|
|
67
|
+
1,
|
|
68
|
+
Math.round(
|
|
69
|
+
wordCount( content, wordCountType ) / AVERAGE_READING_RATE
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return sprintf(
|
|
74
|
+
/* translators: %d is the number of minutes the post will take to read. */
|
|
75
|
+
_n( '%d minute', '%d minutes', minutesToRead ),
|
|
76
|
+
minutesToRead
|
|
77
|
+
);
|
|
78
|
+
}, [ contentStructure, blocks ] );
|
|
79
|
+
|
|
80
|
+
const blockProps = useBlockProps( {
|
|
81
|
+
className: classnames( {
|
|
82
|
+
[ `has-text-align-${ textAlign }` ]: textAlign,
|
|
83
|
+
} ),
|
|
84
|
+
} );
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<>
|
|
88
|
+
<BlockControls group="block">
|
|
89
|
+
<AlignmentControl
|
|
90
|
+
value={ textAlign }
|
|
91
|
+
onChange={ ( nextAlign ) => {
|
|
92
|
+
setAttributes( { textAlign: nextAlign } );
|
|
93
|
+
} }
|
|
94
|
+
/>
|
|
95
|
+
</BlockControls>
|
|
96
|
+
<p { ...blockProps }>{ minutesToReadString }</p>
|
|
97
|
+
</>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default PostTimeToReadEdit;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { SVG, Path } from '@wordpress/components';
|
|
5
|
+
|
|
6
|
+
export default (
|
|
7
|
+
<SVG
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
width="24"
|
|
10
|
+
height="24"
|
|
11
|
+
viewBox="0 0 24 24"
|
|
12
|
+
>
|
|
13
|
+
<Path d="M12 3c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16.5c-4.1 0-7.5-3.4-7.5-7.5S7.9 4.5 12 4.5s7.5 3.4 7.5 7.5-3.4 7.5-7.5 7.5zM12 7l-1 5c0 .3.2.6.4.8l4.2 2.8-2.7-4.1L12 7z" />
|
|
14
|
+
</SVG>
|
|
15
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import initBlock from '../utils/init-block';
|
|
5
|
+
import metadata from './block.json';
|
|
6
|
+
import edit from './edit';
|
|
7
|
+
import icon from './icon';
|
|
8
|
+
|
|
9
|
+
const { name } = metadata;
|
|
10
|
+
export { metadata, name };
|
|
11
|
+
|
|
12
|
+
export const settings = {
|
|
13
|
+
icon,
|
|
14
|
+
edit,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Server-side rendering of the `core/post-time-to-read` block.
|
|
4
|
+
*
|
|
5
|
+
* @package WordPress
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Renders the `core/post-time-to-read` block on the server.
|
|
10
|
+
*
|
|
11
|
+
* @param array $attributes Block attributes.
|
|
12
|
+
* @param string $content Block default content.
|
|
13
|
+
* @param WP_Block $block Block instance.
|
|
14
|
+
* @return string Returns the rendered post author name block.
|
|
15
|
+
*/
|
|
16
|
+
function render_block_core_post_time_to_read( $attributes, $content, $block ) {
|
|
17
|
+
if ( ! isset( $block->context['postId'] ) ) {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
$content = get_the_content();
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* Average reading rate - based on average taken from
|
|
25
|
+
* https://irisreading.com/average-reading-speed-in-various-languages/
|
|
26
|
+
* (Characters/minute used for Chinese rather than words).
|
|
27
|
+
*/
|
|
28
|
+
$average_reading_rate = 189;
|
|
29
|
+
|
|
30
|
+
$word_count_type = wp_get_word_count_type();
|
|
31
|
+
|
|
32
|
+
$minutes_to_read = max( 1, (int) round( wp_word_count( $content, $word_count_type ) / $average_reading_rate ) );
|
|
33
|
+
|
|
34
|
+
$minutes_to_read_string = sprintf(
|
|
35
|
+
/* translators: %d is the number of minutes the post will take to read. */
|
|
36
|
+
_n( '%d minute', '%d minutes', $minutes_to_read ),
|
|
37
|
+
$minutes_to_read
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
$align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
|
|
41
|
+
|
|
42
|
+
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
|
|
43
|
+
|
|
44
|
+
return sprintf(
|
|
45
|
+
'<p %1$s>%2$s</p>',
|
|
46
|
+
$wrapper_attributes,
|
|
47
|
+
$minutes_to_read_string
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Registers the `core/post-time-to-read` block on the server.
|
|
53
|
+
*/
|
|
54
|
+
function register_block_core_post_time_to_read() {
|
|
55
|
+
register_block_type_from_metadata(
|
|
56
|
+
__DIR__ . '/post-time-to-read',
|
|
57
|
+
array(
|
|
58
|
+
'render_callback' => 'render_block_core_post_time_to_read',
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
add_action( 'init', 'register_block_core_post_time_to_read' );
|
package/src/post-title/edit.js
CHANGED
|
@@ -118,6 +118,7 @@ export default function PostTitleEdit( {
|
|
|
118
118
|
<InspectorControls>
|
|
119
119
|
<PanelBody title={ __( 'Link settings' ) }>
|
|
120
120
|
<ToggleControl
|
|
121
|
+
__nextHasNoMarginBottom
|
|
121
122
|
label={ __( 'Make title a link' ) }
|
|
122
123
|
onChange={ () => setAttributes( { isLink: ! isLink } ) }
|
|
123
124
|
checked={ isLink }
|
|
@@ -125,6 +126,7 @@ export default function PostTitleEdit( {
|
|
|
125
126
|
{ isLink && (
|
|
126
127
|
<>
|
|
127
128
|
<ToggleControl
|
|
129
|
+
__nextHasNoMarginBottom
|
|
128
130
|
label={ __( 'Open in new tab' ) }
|
|
129
131
|
onChange={ ( value ) =>
|
|
130
132
|
setAttributes( {
|