-
Notifications
You must be signed in to change notification settings - Fork 3
/
functions.php
76 lines (68 loc) · 2.89 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php declare(strict_types = 1);
/**
* Remote Data Blocks API
*
* This file contains functions, in the global namespace, for registering and
* interacting with Remote Data Blocks.
*/
use RemoteDataBlocks\Config\QueryContext\QueryContextInterface;
use RemoteDataBlocks\Editor\BlockManagement\ConfigRegistry;
/**
* Register a remote data block.
*
* @param string $block_name The block name.
* @param QueryContextInterface $get_query The query used to fetch the remote data.
*/
function register_remote_data_block( string $block_name, QueryContextInterface $get_query ): void {
ConfigRegistry::register_block( $block_name, $get_query );
}
/**
* Register a remote data loop block, which displays a collection of remote data
* items.
*
* @param string $block_name The block name.
* @param QueryContextInterface $get_collection_query The query used to fetch the remote data collection.
*/
function register_remote_data_loop_block( string $block_name, QueryContextInterface $get_collection_query ): void {
ConfigRegistry::register_loop_block( $block_name, $get_collection_query );
}
/**
* Register a remote data list query to allow users to choose a remote data item
* from a list.
*
* @param string $block_name The block name.
* @param QueryContextInterface $get_collection_query The query used to fetch the remote data collection.
*/
function register_remote_data_list_query( string $block_name, QueryContextInterface $get_collection_query ): void {
ConfigRegistry::register_list_query( $block_name, $get_collection_query );
}
/**
* Register a remote data search query to allow users to search for a remote data
* item.
*
* @param string $block_name The block name.
* @param QueryContextInterface $search_collection_query The query used to search the remote data collection.
*/
function register_remote_data_search_query( string $block_name, QueryContextInterface $search_collection_query ): void {
ConfigRegistry::register_search_query( $block_name, $search_collection_query );
}
/**
* Register a block pattern that can used with a remote data block.
*
* @param string $block_name The block name.
* @param string $pattern_title The pattern title.
* @param string $pattern_html The pattern HTML.
* @param array $pattern_options The pattern options.
*/
function register_remote_data_block_pattern( string $block_name, string $pattern_title, string $pattern_html, array $pattern_options = [] ): void {
ConfigRegistry::register_block_pattern( $block_name, $pattern_title, $pattern_html, $pattern_options );
}
/**
* Register a remote data page.
*
* @param string $block_name The block name.
* @param string $slug The page slug.
*/
function register_remote_data_page( string $block_name, string $slug, array $options = [] ): void {
ConfigRegistry::register_page( $block_name, $slug, $options );
}