Skip to content

Commit a9cc4c0

Browse files
committed
fix: use {{cpt_slug}} instead of {{slug}} for post type identifiers
Corrected post type slug references to use the specific {{cpt_slug}} mustache variable instead of the generic {{slug}} (plugin slug) variable. According to generate-plugin.instructions.md, {{cpt_slug}} is the dedicated variable for custom post type slugs (max 20 chars), while {{slug}} is the plugin identifier. Changed: - inc/class-post-types.php: POST_TYPE constant - src/hooks/usePostType.js: Default postType parameter - src/hooks/useFields.js: Default postType parameter - src/hooks/useRepeater.js: Default postType parameter - src/hooks/useCollection.js: Default postType parameter - src/components/PostSelector: Default postType parameter - docs/GENERATE-PLUGIN.md: Documentation example This ensures proper separation between plugin slug and CPT slug during scaffold generation.
1 parent 3c1c268 commit a9cc4c0

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

docs/GENERATE-PLUGIN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ Block registration and components use namespace and textdomain:
218218
/**
219219
* @package {{namespace}}
220220
*/
221-
export default function PostSelector( { postType = '{{slug}}' } ) {
221+
export default function PostSelector( { postType = '{{cpt_slug}}' } ) {
222222
return (
223223
<div className="{{namespace}}-post-selector">
224224
{__( 'Select Post', '{{textdomain}}' )}

inc/class-post-types.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Post_Types {
2323
*
2424
* @var string
2525
*/
26-
const POST_TYPE = '{{slug}}';
26+
const POST_TYPE = '{{cpt_slug}}';
2727

2828
/**
2929
* Constructor.

src/components/PostSelector/PostSelector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { ComboboxControl, Spinner } from '@wordpress/components';
2424
* @return {Element} PostSelector component.
2525
*/
2626
export default function PostSelector({
27-
postType = '{{slug}}',
27+
postType = '{{cpt_slug}}',
2828
value,
2929
onChange,
3030
label = __('Select Post', '{{textdomain}}'),

src/hooks/useCollection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { useSelect } from '@wordpress/data';
1717
*/
1818
export default function useCollection(query = {}) {
1919
const {
20-
postType = '{{slug}}',
20+
postType = '{{cpt_slug}}',
2121
perPage = 6,
2222
page = 1,
2323
order = 'desc',

src/hooks/useFields.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { useSelect } from '@wordpress/data';
1616
*
1717
* @return {Object} Fields data and loading state.
1818
*/
19-
export default function useFields(postId, postType = '{{slug}}') {
19+
export default function useFields(postId, postType = '{{cpt_slug}}') {
2020
return useSelect(
2121
(select) => {
2222
if (!postId) {

src/hooks/usePostType.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { useSelect } from '@wordpress/data';
1616
*
1717
* @return {Object} Post data and loading state.
1818
*/
19-
export default function usePostType(postId, postType = '{{slug}}') {
19+
export default function usePostType(postId, postType = '{{cpt_slug}}') {
2020
return useSelect(
2121
(select) => {
2222
if (!postId) {

src/hooks/useRepeater.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { useSelect } from '@wordpress/data';
2020
export default function useRepeater(
2121
postId,
2222
fieldName,
23-
postType = '{{slug}}'
23+
postType = '{{cpt_slug}}'
2424
) {
2525
return useSelect(
2626
(select) => {

0 commit comments

Comments
 (0)