@wordpress/block-library 9.19.0 → 9.19.1
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 +4 -0
- package/build/latest-posts/edit.js +2 -1
- package/build/latest-posts/edit.js.map +1 -1
- package/build/navigation/use-template-part-area-label.js +7 -6
- package/build/navigation/use-template-part-area-label.js.map +1 -1
- package/build/post-author/edit.js +1 -1
- package/build/post-author/edit.js.map +1 -1
- package/build/post-author-name/edit.js +2 -2
- package/build/post-author-name/edit.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +2 -0
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/order-control.js +3 -2
- package/build/query/edit/inspector-controls/order-control.js.map +1 -1
- package/build/query/utils.js +45 -0
- package/build/query/utils.js.map +1 -1
- package/build/query-total/index.js +2 -2
- package/build/query-total/index.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js +1 -1
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/utils/hooks.js +1 -1
- package/build/template-part/edit/utils/hooks.js.map +1 -1
- package/build-module/latest-posts/edit.js +2 -1
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/navigation/use-template-part-area-label.js +7 -6
- package/build-module/navigation/use-template-part-area-label.js.map +1 -1
- package/build-module/post-author/edit.js +1 -1
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-author-name/edit.js +2 -2
- package/build-module/post-author-name/edit.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +3 -1
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/order-control.js +3 -2
- package/build-module/query/edit/inspector-controls/order-control.js.map +1 -1
- package/build-module/query/utils.js +44 -0
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query-total/index.js +2 -2
- package/build-module/query-total/index.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js +1 -1
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/utils/hooks.js +1 -1
- package/build-module/template-part/edit/utils/hooks.js.map +1 -1
- package/package.json +35 -35
- package/src/latest-posts/edit.js +1 -0
- package/src/navigation/use-template-part-area-label.js +6 -6
- package/src/post-author/edit.js +1 -1
- package/src/post-author-name/edit.js +4 -4
- package/src/query/edit/inspector-controls/index.js +3 -1
- package/src/query/edit/inspector-controls/order-control.js +9 -3
- package/src/query/utils.js +58 -0
- package/src/query-total/block.json +2 -2
- package/src/query-total/index.php +2 -2
- package/src/site-title/index.php +1 -1
- package/src/template-part/edit/advanced-controls.js +1 -1
- package/src/template-part/edit/utils/hooks.js +1 -1
package/src/query/utils.js
CHANGED
|
@@ -6,6 +6,7 @@ import { useMemo } from '@wordpress/element';
|
|
|
6
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
7
7
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
8
8
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
9
10
|
import {
|
|
10
11
|
cloneBlock,
|
|
11
12
|
getBlockSupport,
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
} from '@wordpress/blocks';
|
|
14
15
|
|
|
15
16
|
/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */
|
|
17
|
+
/** @typedef {import('@wordpress/components/build-types/query-controls/types').OrderByOption} OrderByOption */
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* @typedef IHasNameAndId
|
|
@@ -186,6 +188,62 @@ export function useIsPostTypeHierarchical( postType ) {
|
|
|
186
188
|
);
|
|
187
189
|
}
|
|
188
190
|
|
|
191
|
+
/**
|
|
192
|
+
* List of avaiable options to order by.
|
|
193
|
+
*
|
|
194
|
+
* @param {string} postType The post type to check.
|
|
195
|
+
* @return {OrderByOption[]} List of order options.
|
|
196
|
+
*/
|
|
197
|
+
export function useOrderByOptions( postType ) {
|
|
198
|
+
const supportsCustomOrder = useSelect(
|
|
199
|
+
( select ) => {
|
|
200
|
+
const type = select( coreStore ).getPostType( postType );
|
|
201
|
+
return !! type?.supports?.[ 'page-attributes' ];
|
|
202
|
+
},
|
|
203
|
+
[ postType ]
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
return useMemo( () => {
|
|
207
|
+
const orderByOptions = [
|
|
208
|
+
{
|
|
209
|
+
label: __( 'Newest to oldest' ),
|
|
210
|
+
value: 'date/desc',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
label: __( 'Oldest to newest' ),
|
|
214
|
+
value: 'date/asc',
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
/* translators: Label for ordering posts by title in ascending order. */
|
|
218
|
+
label: __( 'A → Z' ),
|
|
219
|
+
value: 'title/asc',
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
/* translators: Label for ordering posts by title in descending order. */
|
|
223
|
+
label: __( 'Z → A' ),
|
|
224
|
+
value: 'title/desc',
|
|
225
|
+
},
|
|
226
|
+
];
|
|
227
|
+
|
|
228
|
+
if ( supportsCustomOrder ) {
|
|
229
|
+
orderByOptions.push(
|
|
230
|
+
{
|
|
231
|
+
/* translators: Label for ordering posts by ascending menu order. */
|
|
232
|
+
label: __( 'Ascending by order' ),
|
|
233
|
+
value: 'menu_order/asc',
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
/* translators: Label for ordering posts by descending menu order. */
|
|
237
|
+
label: __( 'Descending by order' ),
|
|
238
|
+
value: 'menu_order/desc',
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return orderByOptions;
|
|
244
|
+
}, [ supportsCustomOrder ] );
|
|
245
|
+
}
|
|
246
|
+
|
|
189
247
|
/**
|
|
190
248
|
* Hook that returns the query properties' names defined by the active
|
|
191
249
|
* block variation, to determine which block's filters to show.
|
|
@@ -23,7 +23,7 @@ function render_block_core_query_total( $attributes, $content, $block ) {
|
|
|
23
23
|
$wrapper_attributes = get_block_wrapper_attributes();
|
|
24
24
|
if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
|
|
25
25
|
$query_to_use = $wp_query;
|
|
26
|
-
$current_page = max( 1, get_query_var( 'paged', 1 ) );
|
|
26
|
+
$current_page = max( 1, (int) get_query_var( 'paged', 1 ) );
|
|
27
27
|
} else {
|
|
28
28
|
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
|
|
29
29
|
$current_page = isset( $_GET[ $page_key ] ) ? (int) $_GET[ $page_key ] : 1;
|
|
@@ -31,7 +31,7 @@ function render_block_core_query_total( $attributes, $content, $block ) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
$max_rows = $query_to_use->found_posts;
|
|
34
|
-
$posts_per_page = $query_to_use->get( 'posts_per_page' );
|
|
34
|
+
$posts_per_page = (int) $query_to_use->get( 'posts_per_page' );
|
|
35
35
|
|
|
36
36
|
// Calculate the range of posts being displayed.
|
|
37
37
|
$start = ( $current_page - 1 ) * $posts_per_page + 1;
|
package/src/site-title/index.php
CHANGED
|
@@ -31,7 +31,7 @@ function render_block_core_site_title( $attributes ) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
if ( $attributes['isLink'] ) {
|
|
34
|
-
$aria_current =
|
|
34
|
+
$aria_current = ! is_paged() && ( is_front_page() || is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) ? ' aria-current="page"' : '';
|
|
35
35
|
$link_target = ! empty( $attributes['linkTarget'] ) ? $attributes['linkTarget'] : '_self';
|
|
36
36
|
|
|
37
37
|
$site_title = sprintf(
|
|
@@ -36,7 +36,7 @@ export function TemplatePartAdvancedControls( {
|
|
|
36
36
|
|
|
37
37
|
const defaultTemplatePartAreas = useSelect(
|
|
38
38
|
( select ) =>
|
|
39
|
-
select( coreStore ).
|
|
39
|
+
select( coreStore ).getCurrentTheme()
|
|
40
40
|
?.default_template_part_areas || [],
|
|
41
41
|
[]
|
|
42
42
|
);
|
|
@@ -137,7 +137,7 @@ export function useTemplatePartArea( area ) {
|
|
|
137
137
|
return useSelect(
|
|
138
138
|
( select ) => {
|
|
139
139
|
const definedAreas =
|
|
140
|
-
select( coreStore ).
|
|
140
|
+
select( coreStore ).getCurrentTheme()
|
|
141
141
|
?.default_template_part_areas || [];
|
|
142
142
|
|
|
143
143
|
const selectedArea = definedAreas.find(
|