@wp-typia/project-tools 0.16.14 → 0.18.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/dist/runtime/block-generator-service-core.d.ts +1 -1
- package/dist/runtime/block-generator-service-core.js +2 -1
- package/dist/runtime/block-generator-service-spec.d.ts +8 -1
- package/dist/runtime/block-generator-service-spec.js +27 -0
- package/dist/runtime/built-in-block-artifacts.js +1 -0
- package/dist/runtime/built-in-block-code-artifacts.js +14 -1
- package/dist/runtime/built-in-block-code-templates/compound-child.d.ts +2 -2
- package/dist/runtime/built-in-block-code-templates/compound-child.js +30 -2
- package/dist/runtime/built-in-block-code-templates/compound-parent.d.ts +1 -1
- package/dist/runtime/built-in-block-code-templates/compound-parent.js +139 -19
- package/dist/runtime/built-in-block-code-templates/query-loop.d.ts +1 -0
- package/dist/runtime/built-in-block-code-templates/query-loop.js +70 -0
- package/dist/runtime/built-in-block-code-templates.d.ts +1 -0
- package/dist/runtime/built-in-block-code-templates.js +1 -0
- package/dist/runtime/built-in-block-non-ts-artifacts.js +2 -0
- package/dist/runtime/cli-add-block.d.ts +2 -1
- package/dist/runtime/cli-add-block.js +19 -1
- package/dist/runtime/cli-add-shared.d.ts +55 -1
- package/dist/runtime/cli-add-shared.js +101 -2
- package/dist/runtime/cli-add-workspace-assets.d.ts +21 -1
- package/dist/runtime/cli-add-workspace-assets.js +417 -1
- package/dist/runtime/cli-add-workspace-rest.d.ts +14 -0
- package/dist/runtime/cli-add-workspace-rest.js +1060 -0
- package/dist/runtime/cli-add-workspace.d.ts +10 -1
- package/dist/runtime/cli-add-workspace.js +10 -1
- package/dist/runtime/cli-add.d.ts +3 -3
- package/dist/runtime/cli-add.js +2 -2
- package/dist/runtime/cli-core.d.ts +3 -1
- package/dist/runtime/cli-core.js +2 -1
- package/dist/runtime/cli-doctor-workspace.js +135 -1
- package/dist/runtime/cli-help.js +10 -5
- package/dist/runtime/cli-scaffold.d.ts +11 -2
- package/dist/runtime/cli-scaffold.js +137 -36
- package/dist/runtime/cli-templates.d.ts +4 -4
- package/dist/runtime/cli-templates.js +79 -39
- package/dist/runtime/index.d.ts +4 -3
- package/dist/runtime/index.js +3 -2
- package/dist/runtime/local-dev-presets.js +27 -12
- package/dist/runtime/rest-resource-artifacts.d.ts +35 -0
- package/dist/runtime/rest-resource-artifacts.js +158 -0
- package/dist/runtime/scaffold-answer-resolution.d.ts +1 -1
- package/dist/runtime/scaffold-answer-resolution.js +94 -3
- package/dist/runtime/scaffold-apply-utils.d.ts +4 -3
- package/dist/runtime/scaffold-apply-utils.js +34 -17
- package/dist/runtime/scaffold-bootstrap.d.ts +15 -0
- package/dist/runtime/scaffold-bootstrap.js +29 -7
- package/dist/runtime/scaffold-documents.js +9 -9
- package/dist/runtime/scaffold-onboarding.js +17 -1
- package/dist/runtime/scaffold-package-manager-files.js +6 -1
- package/dist/runtime/scaffold-template-variables.js +6 -0
- package/dist/runtime/scaffold.d.ts +15 -1
- package/dist/runtime/scaffold.js +50 -8
- package/dist/runtime/template-defaults.d.ts +7 -0
- package/dist/runtime/template-defaults.js +4 -0
- package/dist/runtime/template-registry.d.ts +1 -1
- package/dist/runtime/template-registry.js +14 -1
- package/dist/runtime/template-render.d.ts +5 -2
- package/dist/runtime/template-render.js +9 -3
- package/dist/runtime/template-source-contracts.d.ts +11 -0
- package/dist/runtime/template-source-external.d.ts +1 -1
- package/dist/runtime/template-source-external.js +45 -13
- package/dist/runtime/template-source-normalization.d.ts +1 -1
- package/dist/runtime/template-source-normalization.js +5 -1
- package/dist/runtime/template-source-remote.d.ts +5 -0
- package/dist/runtime/template-source-remote.js +33 -0
- package/dist/runtime/template-source.js +30 -1
- package/dist/runtime/workspace-inventory.d.ts +43 -1
- package/dist/runtime/workspace-inventory.js +132 -1
- package/dist/runtime/workspace-project.d.ts +1 -1
- package/dist/runtime/workspace-project.js +2 -2
- package/package.json +3 -3
- package/templates/_shared/compound/core/scripts/add-compound-child.ts.mustache +428 -49
- package/templates/query-loop/inc/query-runtime.php.mustache +85 -0
- package/templates/query-loop/package.json.mustache +32 -0
- package/templates/query-loop/src/patterns/grid.php.mustache +49 -0
- package/templates/query-loop/src/patterns/list.php.mustache +48 -0
- package/templates/query-loop/src/query-extension.ts.mustache +41 -0
- package/templates/query-loop/webpack.config.js.mustache +16 -0
- package/templates/query-loop/{{slugKebabCase}}.php.mustache +84 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
3
|
+
exit;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function {{phpPrefix}}_get_query_loop_variation_name() {
|
|
7
|
+
return '{{namespace}}/{{slug}}';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function {{phpPrefix}}_get_query_loop_variation_marker_key() {
|
|
11
|
+
return 'wpTypiaVariation';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function {{phpPrefix}}_extract_query_loop_request_query( WP_REST_Request $request ) {
|
|
15
|
+
$params = $request->get_params();
|
|
16
|
+
|
|
17
|
+
if ( isset( $params['query'] ) && is_array( $params['query'] ) ) {
|
|
18
|
+
return $params['query'];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return is_array( $params ) ? $params : array();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function {{phpPrefix}}_map_query_loop_custom_query_vars( array $query_vars, array $source_query ) {
|
|
25
|
+
unset( $query_vars[ {{phpPrefix}}_get_query_loop_variation_marker_key() ] );
|
|
26
|
+
|
|
27
|
+
$allowed_custom_query_values = array(
|
|
28
|
+
// 'featuredOnly' => isset( $source_query['featuredOnly'] ) ? (bool) $source_query['featuredOnly'] : null,
|
|
29
|
+
// 'eventStatus' => isset( $source_query['eventStatus'] ) ? sanitize_text_field( $source_query['eventStatus'] ) : null,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// Mirror only known custom query keys from `src/query-extension.ts` here when
|
|
33
|
+
// they should affect frontend rendering or editor preview requests. Sanitize
|
|
34
|
+
// and cast values before copying them into WP_Query vars; do not merge the
|
|
35
|
+
// raw source query wholesale.
|
|
36
|
+
foreach ( $allowed_custom_query_values as $key => $value ) {
|
|
37
|
+
if ( null === $value ) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
$query_vars[ $key ] = $value;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return $query_vars;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function {{phpPrefix}}_filter_query_loop_block_query_vars( $query_vars, $block, $page ) {
|
|
48
|
+
if ( ! is_array( $query_vars ) ) {
|
|
49
|
+
return $query_vars;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
$attrs = is_array( $block ) && isset( $block['attrs'] ) && is_array( $block['attrs'] )
|
|
53
|
+
? $block['attrs']
|
|
54
|
+
: array();
|
|
55
|
+
$namespace = isset( $attrs['namespace'] ) && is_string( $attrs['namespace'] )
|
|
56
|
+
? $attrs['namespace']
|
|
57
|
+
: null;
|
|
58
|
+
$source_query = isset( $attrs['query'] ) && is_array( $attrs['query'] )
|
|
59
|
+
? $attrs['query']
|
|
60
|
+
: array();
|
|
61
|
+
|
|
62
|
+
if ( {{phpPrefix}}_get_query_loop_variation_name() !== $namespace ) {
|
|
63
|
+
return $query_vars;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return {{phpPrefix}}_map_query_loop_custom_query_vars( $query_vars, $source_query );
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function {{phpPrefix}}_filter_query_loop_editor_preview_query_vars( $query_vars, $request ) {
|
|
70
|
+
if ( ! is_array( $query_vars ) || ! $request instanceof WP_REST_Request ) {
|
|
71
|
+
return $query_vars;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
$source_query = {{phpPrefix}}_extract_query_loop_request_query( $request );
|
|
75
|
+
$marker_key = {{phpPrefix}}_get_query_loop_variation_marker_key();
|
|
76
|
+
$variation_name = isset( $source_query[ $marker_key ] ) && is_string( $source_query[ $marker_key ] )
|
|
77
|
+
? $source_query[ $marker_key ]
|
|
78
|
+
: null;
|
|
79
|
+
|
|
80
|
+
if ( {{phpPrefix}}_get_query_loop_variation_name() !== $variation_name ) {
|
|
81
|
+
return $query_vars;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {{phpPrefix}}_map_query_loop_custom_query_vars( $query_vars, $source_query );
|
|
85
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{slug}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"packageManager": "bun@1.3.11",
|
|
5
|
+
"description": "{{description}}",
|
|
6
|
+
"author": "{{author}}",
|
|
7
|
+
"license": "GPL-2.0-or-later",
|
|
8
|
+
"main": "build/index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "wp-scripts build --experimental-modules",
|
|
11
|
+
"start": "wp-scripts start --experimental-modules",
|
|
12
|
+
"dev": "wp-scripts start --experimental-modules",
|
|
13
|
+
"lint:js": "wp-scripts lint-js",
|
|
14
|
+
"lint": "bun run lint:js",
|
|
15
|
+
"format": "wp-scripts format",
|
|
16
|
+
"typecheck": "tsc --noEmit"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@wp-typia/block-types": "{{blockTypesPackageVersion}}",
|
|
20
|
+
"@types/wordpress__block-editor": "^11.5.17",
|
|
21
|
+
"@types/wordpress__blocks": "^12.5.18",
|
|
22
|
+
"@wordpress/browserslist-config": "^6.42.0",
|
|
23
|
+
"@wordpress/scripts": "^30.22.0",
|
|
24
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
25
|
+
"prettier": "3.8.2",
|
|
26
|
+
"typescript": "^5.9.2"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@wordpress/blocks": "^15.2.0",
|
|
30
|
+
"@wordpress/i18n": "^6.2.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
3
|
+
exit;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
$content = sprintf(
|
|
7
|
+
<<<'HTML'
|
|
8
|
+
<!-- wp:query {"namespace":"{{namespace}}/{{slug}}","query":{"inherit":false,"postType":"{{queryPostType}}","perPage":6,"order":"desc","orderBy":"date","wpTypiaVariation":"{{namespace}}/{{slug}}"},"displayLayout":{"type":"grid","columns":3}} -->
|
|
9
|
+
<div class="wp-block-query">
|
|
10
|
+
<!-- wp:post-template -->
|
|
11
|
+
<!-- wp:group {"style":{"spacing":{"blockGap":"0.75rem","padding":{"top":"1rem","right":"1rem","bottom":"1rem","left":"1rem"}}},"layout":{"type":"constrained"}} -->
|
|
12
|
+
<div class="wp-block-group" style="padding-top:1rem;padding-right:1rem;padding-bottom:1rem;padding-left:1rem">
|
|
13
|
+
<!-- wp:post-featured-image /-->
|
|
14
|
+
<!-- wp:post-title {"isLink":true} /-->
|
|
15
|
+
<!-- wp:post-excerpt /-->
|
|
16
|
+
</div>
|
|
17
|
+
<!-- /wp:group -->
|
|
18
|
+
<!-- /wp:post-template -->
|
|
19
|
+
|
|
20
|
+
<!-- wp:query-pagination -->
|
|
21
|
+
<!-- wp:query-pagination-previous /-->
|
|
22
|
+
<!-- wp:query-pagination-numbers /-->
|
|
23
|
+
<!-- wp:query-pagination-next /-->
|
|
24
|
+
<!-- /wp:query-pagination -->
|
|
25
|
+
|
|
26
|
+
<!-- wp:query-no-results -->
|
|
27
|
+
<!-- wp:paragraph -->
|
|
28
|
+
<p>%s</p>
|
|
29
|
+
<!-- /wp:paragraph -->
|
|
30
|
+
<!-- /wp:query-no-results -->
|
|
31
|
+
</div>
|
|
32
|
+
<!-- /wp:query -->
|
|
33
|
+
HTML,
|
|
34
|
+
esc_html__( 'No items matched this preset yet.', '{{textDomain}}' )
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
register_block_pattern(
|
|
38
|
+
'{{namespace}}/{{slug}}-grid',
|
|
39
|
+
array(
|
|
40
|
+
'title' => __( '{{title}} Grid', '{{textDomain}}' ),
|
|
41
|
+
'description' => __( 'A connected grid layout preset for the {{title}} Query Loop variation.', '{{textDomain}}' ),
|
|
42
|
+
'categories' => array( '{{slug}}-query-loop' ),
|
|
43
|
+
'blockTypes' => array( 'core/query' ),
|
|
44
|
+
'postTypes' => array( '{{queryPostType}}' ),
|
|
45
|
+
'inserter' => true,
|
|
46
|
+
'viewportWidth' => 1280,
|
|
47
|
+
'content' => $content,
|
|
48
|
+
)
|
|
49
|
+
);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
3
|
+
exit;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
$content = sprintf(
|
|
7
|
+
<<<'HTML'
|
|
8
|
+
<!-- wp:query {"namespace":"{{namespace}}/{{slug}}","query":{"inherit":false,"postType":"{{queryPostType}}","perPage":4,"order":"desc","orderBy":"date","wpTypiaVariation":"{{namespace}}/{{slug}}"}} -->
|
|
9
|
+
<div class="wp-block-query">
|
|
10
|
+
<!-- wp:post-template -->
|
|
11
|
+
<!-- wp:group {"style":{"spacing":{"blockGap":"1rem","padding":{"top":"1.25rem","bottom":"1.25rem"}}},"layout":{"type":"constrained"}} -->
|
|
12
|
+
<div class="wp-block-group" style="padding-top:1.25rem;padding-bottom:1.25rem">
|
|
13
|
+
<!-- wp:post-title {"isLink":true} /-->
|
|
14
|
+
<!-- wp:post-date /-->
|
|
15
|
+
<!-- wp:post-excerpt {"moreText":"Continue reading"} /-->
|
|
16
|
+
</div>
|
|
17
|
+
<!-- /wp:group -->
|
|
18
|
+
<!-- /wp:post-template -->
|
|
19
|
+
|
|
20
|
+
<!-- wp:query-pagination -->
|
|
21
|
+
<!-- wp:query-pagination-previous /-->
|
|
22
|
+
<!-- wp:query-pagination-next /-->
|
|
23
|
+
<!-- /wp:query-pagination -->
|
|
24
|
+
|
|
25
|
+
<!-- wp:query-no-results -->
|
|
26
|
+
<!-- wp:paragraph -->
|
|
27
|
+
<p>%s</p>
|
|
28
|
+
<!-- /wp:paragraph -->
|
|
29
|
+
<!-- /wp:query-no-results -->
|
|
30
|
+
</div>
|
|
31
|
+
<!-- /wp:query -->
|
|
32
|
+
HTML,
|
|
33
|
+
esc_html__( 'No items matched this preset yet.', '{{textDomain}}' )
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
register_block_pattern(
|
|
37
|
+
'{{namespace}}/{{slug}}-list',
|
|
38
|
+
array(
|
|
39
|
+
'title' => __( '{{title}} List', '{{textDomain}}' ),
|
|
40
|
+
'description' => __( 'A connected list layout preset for the {{title}} Query Loop variation.', '{{textDomain}}' ),
|
|
41
|
+
'categories' => array( '{{slug}}-query-loop' ),
|
|
42
|
+
'blockTypes' => array( 'core/query' ),
|
|
43
|
+
'postTypes' => array( '{{queryPostType}}' ),
|
|
44
|
+
'inserter' => true,
|
|
45
|
+
'viewportWidth' => 1280,
|
|
46
|
+
'content' => $content,
|
|
47
|
+
)
|
|
48
|
+
);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type QueryLoopEditorExtensionContext = {
|
|
2
|
+
variationName: string;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export type QueryLoopCustomQuerySeed = Record<string, unknown>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Extend the generated Query Loop variation with variation-specific query params.
|
|
9
|
+
*
|
|
10
|
+
* Add custom keys here only when the variation should always seed them. Runtime
|
|
11
|
+
* parity hooks in `inc/query-runtime.php` can read the same keys later from the
|
|
12
|
+
* Query Loop `query` object.
|
|
13
|
+
*/
|
|
14
|
+
export function getQueryLoopCustomQuerySeed(): QueryLoopCustomQuerySeed {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Add extra inspector controls by key when your custom query seed needs them.
|
|
20
|
+
*
|
|
21
|
+
* Keep the generated defaults in `src/index.ts` and return only the additional
|
|
22
|
+
* control ids that your variation-specific query params rely on.
|
|
23
|
+
*/
|
|
24
|
+
export function getQueryLoopCustomAllowedControls(): string[] {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Register optional editor-only extension hooks for custom Query Loop params.
|
|
30
|
+
*
|
|
31
|
+
* This stays a no-op by default. When you need custom inspector UI, add your
|
|
32
|
+
* `editor.BlockEdit` filters or other editor hooks here so `src/index.ts` can
|
|
33
|
+
* keep variation registration focused on identity and default query values. If
|
|
34
|
+
* those hooks introduce frontend-affecting query params, mirror them in
|
|
35
|
+
* `inc/query-runtime.php` so editor preview and frontend rendering stay aligned.
|
|
36
|
+
*/
|
|
37
|
+
export function registerQueryLoopEditorExtensions(
|
|
38
|
+
_context: QueryLoopEditorExtensionContext,
|
|
39
|
+
): void {
|
|
40
|
+
// Add optional editor hooks here when this variation introduces custom query UI.
|
|
41
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const path = require("node:path");
|
|
2
|
+
const defaultConfig = require("@wordpress/scripts/config/webpack.config");
|
|
3
|
+
|
|
4
|
+
const queryLoopEntry = {
|
|
5
|
+
index: path.resolve(process.cwd(), "src/index.ts"),
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
module.exports = Array.isArray(defaultConfig)
|
|
9
|
+
? defaultConfig.map((config) => ({
|
|
10
|
+
...config,
|
|
11
|
+
entry: config?.output?.module ? config.entry : queryLoopEntry,
|
|
12
|
+
}))
|
|
13
|
+
: {
|
|
14
|
+
...defaultConfig,
|
|
15
|
+
entry: queryLoopEntry,
|
|
16
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Plugin Name: {{title}}
|
|
4
|
+
* Description: {{description}}
|
|
5
|
+
* Version: 0.1.0
|
|
6
|
+
* Requires at least: 6.7
|
|
7
|
+
* Tested up to: 6.9
|
|
8
|
+
* Requires PHP: 8.0
|
|
9
|
+
* Author: {{author}}
|
|
10
|
+
* License: GPL-2.0-or-later
|
|
11
|
+
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
12
|
+
* Text Domain: {{textDomain}}
|
|
13
|
+
* Domain Path: /languages
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
17
|
+
exit;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
require_once __DIR__ . '/inc/query-runtime.php';
|
|
21
|
+
|
|
22
|
+
function {{phpPrefix}}_load_textdomain() {
|
|
23
|
+
load_plugin_textdomain(
|
|
24
|
+
'{{textDomain}}',
|
|
25
|
+
false,
|
|
26
|
+
dirname( plugin_basename( __FILE__ ) ) . '/languages'
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function {{phpPrefix}}_register_query_loop_pattern_category() {
|
|
31
|
+
if ( ! function_exists( 'register_block_pattern_category' ) ) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
register_block_pattern_category(
|
|
36
|
+
'{{slug}}-query-loop',
|
|
37
|
+
array(
|
|
38
|
+
'label' => __( '{{title}} Query Loop', '{{textDomain}}' ),
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function {{phpPrefix}}_register_query_loop_patterns() {
|
|
44
|
+
if ( ! function_exists( 'register_block_pattern' ) ) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
foreach ( glob( __DIR__ . '/src/patterns/*.php' ) ?: array() as $pattern_module ) {
|
|
49
|
+
require $pattern_module;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function {{phpPrefix}}_register_query_loop_variation_script() {
|
|
54
|
+
$script_path = __DIR__ . '/build/index.js';
|
|
55
|
+
$script_asset_path = __DIR__ . '/build/index.asset.php';
|
|
56
|
+
|
|
57
|
+
if ( ! file_exists( $script_path ) || ! file_exists( $script_asset_path ) ) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
$asset = require $script_asset_path;
|
|
62
|
+
$handle = '{{phpPrefix}}_query_loop_variation';
|
|
63
|
+
|
|
64
|
+
wp_register_script(
|
|
65
|
+
$handle,
|
|
66
|
+
plugins_url( 'build/index.js', __FILE__ ),
|
|
67
|
+
is_array( $asset ) && isset( $asset['dependencies'] ) ? $asset['dependencies'] : array(),
|
|
68
|
+
is_array( $asset ) && isset( $asset['version'] ) ? $asset['version'] : filemtime( $script_path ),
|
|
69
|
+
true
|
|
70
|
+
);
|
|
71
|
+
wp_set_script_translations( $handle, '{{textDomain}}', __DIR__ . '/languages' );
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function {{phpPrefix}}_enqueue_query_loop_variation_script() {
|
|
75
|
+
{{phpPrefix}}_register_query_loop_variation_script();
|
|
76
|
+
wp_enqueue_script( '{{phpPrefix}}_query_loop_variation' );
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
add_action( 'init', '{{phpPrefix}}_load_textdomain' );
|
|
80
|
+
add_action( 'init', '{{phpPrefix}}_register_query_loop_pattern_category' );
|
|
81
|
+
add_action( 'init', '{{phpPrefix}}_register_query_loop_patterns', 20 );
|
|
82
|
+
add_action( 'enqueue_block_editor_assets', '{{phpPrefix}}_enqueue_query_loop_variation_script' );
|
|
83
|
+
add_filter( 'query_loop_block_query_vars', '{{phpPrefix}}_filter_query_loop_block_query_vars', 10, 3 );
|
|
84
|
+
add_filter( 'rest_{{queryPostType}}_query', '{{phpPrefix}}_filter_query_loop_editor_preview_query_vars', 10, 2 );
|