soinproduction-gutenberg 0.1.4 → 0.1.5

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.
Files changed (81) hide show
  1. package/adapters/wordpress/blueprint.ts +2 -2
  2. package/adapters/wordpress/renderer.php +12 -0
  3. package/bootstrap.php +6 -3
  4. package/components/social-links/index.tsx +29 -0
  5. package/components/social-links/manifest.json +4 -0
  6. package/dist/adapters/wordpress/blueprint.d.ts +2 -0
  7. package/dist/adapters/wordpress/blueprint.js +3 -2
  8. package/dist/adapters/wordpress/blueprint.js.map +2 -2
  9. package/dist/adapters/wordpress/renderer.php +12 -0
  10. package/dist/bootstrap.php +6 -3
  11. package/dist/components/social-links/index.d.ts +6 -0
  12. package/dist/components/social-links/index.js +25 -0
  13. package/dist/components/social-links/index.js.map +7 -0
  14. package/dist/components/social-links/manifest.json +4 -0
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.js +2 -0
  17. package/dist/index.js.map +2 -2
  18. package/dist/tooling/build-editor.mjs +1 -1
  19. package/dist/tooling/build-package.mjs +1 -1
  20. package/dist/tooling/cli.mjs +93 -40
  21. package/dist/tooling/create-module.mjs +1 -2
  22. package/dist/tooling/create-post-type.mjs +116 -0
  23. package/dist/tooling/init-theme.mjs +183 -0
  24. package/dist/tooling/prepare-project.mjs +2 -2
  25. package/dist/tooling/smoke-package.mjs +5 -3
  26. package/dist/wordpress/admin/appearance.php +24 -0
  27. package/dist/wordpress/api/content.php +122 -0
  28. package/dist/wordpress/api/modals.php +6 -0
  29. package/dist/wordpress/blocks.php +23 -0
  30. package/dist/wordpress/bootstrap.php +26 -0
  31. package/dist/wordpress/breakpoints.php +37 -0
  32. package/dist/wordpress/documents.php +142 -0
  33. package/dist/wordpress/editor.php +69 -0
  34. package/dist/wordpress/examples/post-type.example.php +65 -0
  35. package/dist/wordpress/frontend.php +7 -0
  36. package/dist/wordpress/integrations.php +60 -0
  37. package/dist/wordpress/options/archives.php +40 -0
  38. package/dist/wordpress/patterns.php +19 -0
  39. package/dist/wordpress/post-types/collections.php +77 -0
  40. package/dist/wordpress/post-types/modals.php +91 -0
  41. package/dist/wordpress/post-types/site-parts.php +25 -0
  42. package/dist/wordpress/rendering/bootstrap.php +95 -0
  43. package/dist/wordpress/rendering/performance.php +67 -0
  44. package/dist/wordpress/routing/archives.php +120 -0
  45. package/dist/wordpress/routing/headless.php +18 -0
  46. package/dist/wordpress/seo.php +110 -0
  47. package/dist/wordpress/setup.php +11 -0
  48. package/dist/wordpress/svg.php +36 -0
  49. package/index.tsx +1 -0
  50. package/package.json +2 -1
  51. package/tooling/build-editor.mjs +1 -1
  52. package/tooling/build-package.mjs +1 -1
  53. package/tooling/cli.mjs +93 -40
  54. package/tooling/create-module.mjs +1 -2
  55. package/tooling/create-post-type.mjs +116 -0
  56. package/tooling/init-theme.mjs +183 -0
  57. package/tooling/prepare-project.mjs +2 -2
  58. package/tooling/smoke-package.mjs +5 -3
  59. package/wordpress/admin/appearance.php +24 -0
  60. package/wordpress/api/content.php +122 -0
  61. package/wordpress/api/modals.php +6 -0
  62. package/wordpress/blocks.php +23 -0
  63. package/wordpress/bootstrap.php +26 -0
  64. package/wordpress/breakpoints.php +37 -0
  65. package/wordpress/documents.php +142 -0
  66. package/wordpress/editor.php +69 -0
  67. package/wordpress/examples/post-type.example.php +65 -0
  68. package/wordpress/frontend.php +7 -0
  69. package/wordpress/integrations.php +60 -0
  70. package/wordpress/options/archives.php +40 -0
  71. package/wordpress/patterns.php +19 -0
  72. package/wordpress/post-types/collections.php +77 -0
  73. package/wordpress/post-types/modals.php +91 -0
  74. package/wordpress/post-types/site-parts.php +25 -0
  75. package/wordpress/rendering/bootstrap.php +95 -0
  76. package/wordpress/rendering/performance.php +67 -0
  77. package/wordpress/routing/archives.php +120 -0
  78. package/wordpress/routing/headless.php +18 -0
  79. package/wordpress/seo.php +110 -0
  80. package/wordpress/setup.php +11 -0
  81. package/wordpress/svg.php +36 -0
@@ -3,7 +3,7 @@ import {Children, Fragment, isValidElement, type ReactNode} from 'react';
3
3
  const marker = (name: string) => Object.assign((_props: any) => null, {kitName: name});
4
4
  export const Section = marker('Section'), Text = marker('Text'), Heading = marker('Heading'),
5
5
  Paragraphs = marker('Paragraphs'), Image = marker('Image'), Icon = marker('Icon'),
6
- Background = marker('Background'), Buttons = marker('Buttons'), Button = marker('Button'), List = marker('List'),
6
+ Background = marker('Background'), Buttons = marker('Buttons'), SocialLinks = marker('SocialLinks'), Button = marker('Button'), List = marker('List'),
7
7
  PricingPlans = marker('PricingPlans'), ReviewsCarousel = marker('ReviewsCarousel'), Form = marker('Form'), Records = marker('Records'), RecordEdit = marker('RecordEdit'), RecordImage = marker('RecordImage'),
8
8
  RecordDate = marker('RecordDate'), RecordTitle = marker('RecordTitle'), RecordExcerpt = marker('RecordExcerpt'), RecordLink = marker('RecordLink'),
9
9
  RecordIndex = marker('RecordIndex'), Drag = marker('Drag'), Cols = marker('Cols'), Toggle = marker('Toggle'),
@@ -26,7 +26,7 @@ function describe(node: ReactNode): any[] {
26
26
 
27
27
  export function section(meta: any, View: () => ReactNode) {
28
28
  const template = describe(View());
29
- const staticTypes = new Set(['#text','Section','Text','Heading','Paragraphs','Image','Icon','Background','Buttons','Button','Show','Toggle','Choice']);
29
+ const staticTypes = new Set(['#text','Section','Text','Heading','Paragraphs','Image','Icon','Background','Buttons','SocialLinks','Button','Show','Toggle','Choice']);
30
30
  const isStatic = (nodes:any[]):boolean => nodes.every(node => (staticTypes.has(node.type) || /^[a-z]/.test(node.type)) && isStatic(node.children ?? []));
31
31
  return {name: 'site/' + meta.slug, title: meta.title, template, static: isStatic(template)};
32
32
  }
@@ -43,6 +43,17 @@ function button(array $value,?string $fallback=null,array $site=[]): string {
43
43
  }
44
44
  return tag('a',['href'=>esc_url($url),'class'=>$class,'data-modal-plan'=>$value['plan']??null],$label);
45
45
  }
46
+ function social_links(array $links, string $class = '', string $style = 'text'): string {
47
+ $labels = ['instagram'=>'Instagram', 'facebook'=>'Facebook', 'telegram'=>'Telegram', 'youtube'=>'YouTube', 'tiktok'=>'TikTok', 'linkedin'=>'LinkedIn'];
48
+ $html = '';
49
+ foreach ($labels as $network => $label) {
50
+ $url = $links[$network] ?? '';
51
+ if (is_string($url) && preg_match('~^https?://[^/]+~i', $url)) {
52
+ $html .= button(['text'=>$label, 'url'=>$url], $style);
53
+ }
54
+ }
55
+ return $html === '' ? '' : tag('div', ['class'=>$class], $html);
56
+ }
46
57
  /** Mirrors `flowPlacement` in frontend/kit/flow-layout.ts. */
47
58
  function flow_placement(int $grid,array $column,array $palette,int $max_col): array {
48
59
  $span=min($grid,max(1,(int)($column['span']??0)?:(int)($palette['span']??0)?:(int)round($grid/max(1,$max_col))));
@@ -161,6 +172,7 @@ function node(array $node,array $context): string {
161
172
  case 'Show':
162
173
  $visible=is_array($p['when'])?(bool)array_filter($p['when'],fn($key)=>trim(wp_strip_all_tags((string)($data[$key]??'')))!==''):(isset($p['is'])?($data[$p['when']]??null)===$p['is']:!empty($data[$p['when']]));return $visible?nodes($children,$context):'';
163
174
  case 'Button':return button(is_array($value)?$value:[],$p['style']??null,$site);
175
+ case 'SocialLinks':return social_links($site['settings']['socialLinks']??[],$class,$p['buttonStyle']??'text');
164
176
  case 'Buttons':$html='';foreach(is_array($value)?$value:[] as $i=>$button)$html.=button($button,$p['styles'][$i]??null,$site);return tag('div',['class'=>$class],$html);
165
177
  case 'Background':case 'Media':
166
178
  if(!$value)return '';if(is_string($value)||($value['type']??'image')==='image')return image(is_string($value)?$value:['url'=>$value['image']??$value['url']??'','alt'=>$value['alt']??''],$class?:'absolute inset-0 h-full w-full object-cover');
package/bootstrap.php CHANGED
@@ -3,7 +3,10 @@ namespace SiteTheme\Kit;
3
3
  defined('ABSPATH') || exit;
4
4
  /** One host connection; generated entries belong to components and modules. */
5
5
  require_once __DIR__.'/adapters/next/runtime.php';
6
- require_once __DIR__.'/admin-ui/bootstrap.php';
7
- foreach (require __DIR__.'/generated/modules.php' as $entry) {
8
- require_once __DIR__.'/'.$entry;
6
+ if (function_exists('add_action')) {
7
+ require_once __DIR__.'/admin-ui/bootstrap.php';
8
+ foreach (require __DIR__.'/generated/modules.php' as $entry) {
9
+ require_once __DIR__.'/'.$entry;
10
+ }
9
11
  }
12
+ require_once __DIR__.'/wordpress/bootstrap.php';
@@ -0,0 +1,29 @@
1
+ 'use client';
2
+
3
+ import { useSite } from '../../core/content/context.js';
4
+ import { buttonClasses } from '../../core/ui/button-appearance.js';
5
+
6
+ const networks = {
7
+ instagram: 'Instagram',
8
+ facebook: 'Facebook',
9
+ telegram: 'Telegram',
10
+ youtube: 'YouTube',
11
+ tiktok: 'TikTok',
12
+ linkedin: 'LinkedIn',
13
+ };
14
+
15
+ type SocialLinksProps = {
16
+ className?: string;
17
+ buttonStyle?: string;
18
+ };
19
+
20
+ export function SocialLinks({ className, buttonStyle = 'text' }: SocialLinksProps) {
21
+ const links = useSite().settings?.socialLinks ?? {};
22
+ const buttons = Object.entries(networks).flatMap(([network, label]) => {
23
+ const url = links[network];
24
+ if (typeof url !== 'string' || !/^https?:\/\/[^/]+/i.test(url)) return [];
25
+ return <a key={network} href={url} className={buttonClasses("is-style-studio-" + buttonStyle)}>{label}</a>;
26
+ });
27
+
28
+ return buttons.length ? <div className={className}>{buttons}</div> : null;
29
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "id": "social-links",
3
+ "dependencies": []
4
+ }
@@ -15,6 +15,8 @@ export declare const Section: ((_props: any) => null) & {
15
15
  kitName: string;
16
16
  }, Buttons: ((_props: any) => null) & {
17
17
  kitName: string;
18
+ }, SocialLinks: ((_props: any) => null) & {
19
+ kitName: string;
18
20
  }, Button: ((_props: any) => null) & {
19
21
  kitName: string;
20
22
  }, List: ((_props: any) => null) & {
@@ -1,6 +1,6 @@
1
1
  import { Children, Fragment, isValidElement } from "react";
2
2
  const marker = (name) => Object.assign((_props) => null, { kitName: name });
3
- const Section = marker("Section"), Text = marker("Text"), Heading = marker("Heading"), Paragraphs = marker("Paragraphs"), Image = marker("Image"), Icon = marker("Icon"), Background = marker("Background"), Buttons = marker("Buttons"), Button = marker("Button"), List = marker("List"), PricingPlans = marker("PricingPlans"), ReviewsCarousel = marker("ReviewsCarousel"), Form = marker("Form"), Records = marker("Records"), RecordEdit = marker("RecordEdit"), RecordImage = marker("RecordImage"), RecordDate = marker("RecordDate"), RecordTitle = marker("RecordTitle"), RecordExcerpt = marker("RecordExcerpt"), RecordLink = marker("RecordLink"), RecordIndex = marker("RecordIndex"), Drag = marker("Drag"), Cols = marker("Cols"), Toggle = marker("Toggle"), Choice = marker("Choice"), Show = marker("Show"), Area = marker("Area"), Gallery = marker("Gallery"), Accordion = marker("Accordion"), AccordionItem = marker("AccordionItem"), AccordionTrigger = marker("AccordionTrigger"), AccordionContent = marker("AccordionContent"), Slider = marker("Slider"), SliderButton = marker("SliderButton"), SliderPagination = marker("SliderPagination"), RecordText = marker("RecordText"), RecordContent = marker("RecordContent"), Media = marker("Media");
3
+ const Section = marker("Section"), Text = marker("Text"), Heading = marker("Heading"), Paragraphs = marker("Paragraphs"), Image = marker("Image"), Icon = marker("Icon"), Background = marker("Background"), Buttons = marker("Buttons"), SocialLinks = marker("SocialLinks"), Button = marker("Button"), List = marker("List"), PricingPlans = marker("PricingPlans"), ReviewsCarousel = marker("ReviewsCarousel"), Form = marker("Form"), Records = marker("Records"), RecordEdit = marker("RecordEdit"), RecordImage = marker("RecordImage"), RecordDate = marker("RecordDate"), RecordTitle = marker("RecordTitle"), RecordExcerpt = marker("RecordExcerpt"), RecordLink = marker("RecordLink"), RecordIndex = marker("RecordIndex"), Drag = marker("Drag"), Cols = marker("Cols"), Toggle = marker("Toggle"), Choice = marker("Choice"), Show = marker("Show"), Area = marker("Area"), Gallery = marker("Gallery"), Accordion = marker("Accordion"), AccordionItem = marker("AccordionItem"), AccordionTrigger = marker("AccordionTrigger"), AccordionContent = marker("AccordionContent"), Slider = marker("Slider"), SliderButton = marker("SliderButton"), SliderPagination = marker("SliderPagination"), RecordText = marker("RecordText"), RecordContent = marker("RecordContent"), Media = marker("Media");
4
4
  function describe(node) {
5
5
  return Children.toArray(node).flatMap((child) => {
6
6
  if (!isValidElement(child)) return [{ type: "#text", value: String(child) }];
@@ -15,7 +15,7 @@ function describe(node) {
15
15
  }
16
16
  function section(meta, View) {
17
17
  const template = describe(View());
18
- const staticTypes = /* @__PURE__ */ new Set(["#text", "Section", "Text", "Heading", "Paragraphs", "Image", "Icon", "Background", "Buttons", "Button", "Show", "Toggle", "Choice"]);
18
+ const staticTypes = /* @__PURE__ */ new Set(["#text", "Section", "Text", "Heading", "Paragraphs", "Image", "Icon", "Background", "Buttons", "SocialLinks", "Button", "Show", "Toggle", "Choice"]);
19
19
  const isStatic = (nodes) => nodes.every((node) => (staticTypes.has(node.type) || /^[a-z]/.test(node.type)) && isStatic(node.children ?? []));
20
20
  return { name: "site/" + meta.slug, title: meta.title, template, static: isStatic(template) };
21
21
  }
@@ -56,6 +56,7 @@ export {
56
56
  Slider,
57
57
  SliderButton,
58
58
  SliderPagination,
59
+ SocialLinks,
59
60
  Text,
60
61
  Toggle,
61
62
  section
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../adapters/wordpress/blueprint.ts"],
4
- "sourcesContent": ["import {Children, Fragment, isValidElement, type ReactNode} from 'react';\n\nconst marker = (name: string) => Object.assign((_props: any) => null, {kitName: name});\nexport const Section = marker('Section'), Text = marker('Text'), Heading = marker('Heading'),\n Paragraphs = marker('Paragraphs'), Image = marker('Image'), Icon = marker('Icon'),\n Background = marker('Background'), Buttons = marker('Buttons'), Button = marker('Button'), List = marker('List'),\n PricingPlans = marker('PricingPlans'), ReviewsCarousel = marker('ReviewsCarousel'), Form = marker('Form'), Records = marker('Records'), RecordEdit = marker('RecordEdit'), RecordImage = marker('RecordImage'),\n RecordDate = marker('RecordDate'), RecordTitle = marker('RecordTitle'), RecordExcerpt = marker('RecordExcerpt'), RecordLink = marker('RecordLink'),\n RecordIndex = marker('RecordIndex'), Drag = marker('Drag'), Cols = marker('Cols'), Toggle = marker('Toggle'),\n Choice = marker('Choice'), Show = marker('Show'), Area = marker('Area'), Gallery = marker('Gallery'),\n Accordion = marker('Accordion'), AccordionItem = marker('AccordionItem'), AccordionTrigger = marker('AccordionTrigger'), AccordionContent = marker('AccordionContent'),\n Slider = marker('Slider'), SliderButton = marker('SliderButton'), SliderPagination = marker('SliderPagination'), RecordText = marker('RecordText'), RecordContent = marker('RecordContent'), Media = marker('Media');\n\nfunction describe(node: ReactNode): any[] {\n return Children.toArray(node).flatMap(child => {\n if (!isValidElement(child)) return [{type: '#text', value: String(child)}];\n if (child.type === Fragment) return describe((child.props as any).children);\n const props = {...child.props as any};\n delete props.children;\n const type = typeof child.type === 'string' ? child.type : (child.type as any).kitName;\n if (!type) throw new Error('WordPress compiler: unsupported React component. Supply an adapter before using it in a portable section.');\n for (const [key, value] of Object.entries(props)) if (typeof value === 'function') throw new Error(`WordPress compiler: callback ${key} cannot be serialized`);\n return [{type, props, children: describe((child.props as any).children)}];\n });\n}\n\nexport function section(meta: any, View: () => ReactNode) {\n const template = describe(View());\n const staticTypes = new Set(['#text','Section','Text','Heading','Paragraphs','Image','Icon','Background','Buttons','Button','Show','Toggle','Choice']);\n const isStatic = (nodes:any[]):boolean => nodes.every(node => (staticTypes.has(node.type) || /^[a-z]/.test(node.type)) && isStatic(node.children ?? []));\n return {name: 'site/' + meta.slug, title: meta.title, template, static: isStatic(template)};\n}\n"],
5
- "mappings": "AAAA,SAAQ,UAAU,UAAU,sBAAqC;AAEjE,MAAM,SAAS,CAAC,SAAiB,OAAO,OAAO,CAAC,WAAgB,MAAM,EAAC,SAAS,KAAI,CAAC;AAC9E,MAAM,UAAU,OAAO,SAAS,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GACvF,aAAa,OAAO,YAAY,GAAG,QAAQ,OAAO,OAAO,GAAG,OAAO,OAAO,MAAM,GAChF,aAAa,OAAO,YAAY,GAAG,UAAU,OAAO,SAAS,GAAG,SAAS,OAAO,QAAQ,GAAG,OAAO,OAAO,MAAM,GAC/G,eAAe,OAAO,cAAc,GAAG,kBAAkB,OAAO,iBAAiB,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GAAG,aAAa,OAAO,YAAY,GAAG,cAAc,OAAO,aAAa,GAC7M,aAAa,OAAO,YAAY,GAAG,cAAc,OAAO,aAAa,GAAG,gBAAgB,OAAO,eAAe,GAAG,aAAa,OAAO,YAAY,GACjJ,cAAc,OAAO,aAAa,GAAG,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO,MAAM,GAAG,SAAS,OAAO,QAAQ,GAC3G,SAAS,OAAO,QAAQ,GAAG,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GACnG,YAAY,OAAO,WAAW,GAAG,gBAAgB,OAAO,eAAe,GAAG,mBAAmB,OAAO,kBAAkB,GAAG,mBAAmB,OAAO,kBAAkB,GACrK,SAAS,OAAO,QAAQ,GAAG,eAAe,OAAO,cAAc,GAAG,mBAAmB,OAAO,kBAAkB,GAAG,aAAa,OAAO,YAAY,GAAG,gBAAgB,OAAO,eAAe,GAAG,QAAQ,OAAO,OAAO;AAEvN,SAAS,SAAS,MAAwB;AACtC,SAAO,SAAS,QAAQ,IAAI,EAAE,QAAQ,WAAS;AAC3C,QAAI,CAAC,eAAe,KAAK,EAAG,QAAO,CAAC,EAAC,MAAM,SAAS,OAAO,OAAO,KAAK,EAAC,CAAC;AACzE,QAAI,MAAM,SAAS,SAAU,QAAO,SAAU,MAAM,MAAc,QAAQ;AAC1E,UAAM,QAAQ,EAAC,GAAG,MAAM,MAAY;AACpC,WAAO,MAAM;AACb,UAAM,OAAO,OAAO,MAAM,SAAS,WAAW,MAAM,OAAQ,MAAM,KAAa;AAC/E,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,2GAA2G;AACtI,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,EAAG,KAAI,OAAO,UAAU,WAAY,OAAM,IAAI,MAAM,gCAAgC,GAAG,uBAAuB;AAC7J,WAAO,CAAC,EAAC,MAAM,OAAO,UAAU,SAAU,MAAM,MAAc,QAAQ,EAAC,CAAC;AAAA,EAC5E,CAAC;AACL;AAEO,SAAS,QAAQ,MAAW,MAAuB;AACtD,QAAM,WAAW,SAAS,KAAK,CAAC;AAChC,QAAM,cAAc,oBAAI,IAAI,CAAC,SAAQ,WAAU,QAAO,WAAU,cAAa,SAAQ,QAAO,cAAa,WAAU,UAAS,QAAO,UAAS,QAAQ,CAAC;AACrJ,QAAM,WAAW,CAAC,UAAwB,MAAM,MAAM,WAAS,YAAY,IAAI,KAAK,IAAI,KAAK,SAAS,KAAK,KAAK,IAAI,MAAM,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC;AACvJ,SAAO,EAAC,MAAM,UAAU,KAAK,MAAM,OAAO,KAAK,OAAO,UAAU,QAAQ,SAAS,QAAQ,EAAC;AAC9F;",
4
+ "sourcesContent": ["import {Children, Fragment, isValidElement, type ReactNode} from 'react';\n\nconst marker = (name: string) => Object.assign((_props: any) => null, {kitName: name});\nexport const Section = marker('Section'), Text = marker('Text'), Heading = marker('Heading'),\n Paragraphs = marker('Paragraphs'), Image = marker('Image'), Icon = marker('Icon'),\n Background = marker('Background'), Buttons = marker('Buttons'), SocialLinks = marker('SocialLinks'), Button = marker('Button'), List = marker('List'),\n PricingPlans = marker('PricingPlans'), ReviewsCarousel = marker('ReviewsCarousel'), Form = marker('Form'), Records = marker('Records'), RecordEdit = marker('RecordEdit'), RecordImage = marker('RecordImage'),\n RecordDate = marker('RecordDate'), RecordTitle = marker('RecordTitle'), RecordExcerpt = marker('RecordExcerpt'), RecordLink = marker('RecordLink'),\n RecordIndex = marker('RecordIndex'), Drag = marker('Drag'), Cols = marker('Cols'), Toggle = marker('Toggle'),\n Choice = marker('Choice'), Show = marker('Show'), Area = marker('Area'), Gallery = marker('Gallery'),\n Accordion = marker('Accordion'), AccordionItem = marker('AccordionItem'), AccordionTrigger = marker('AccordionTrigger'), AccordionContent = marker('AccordionContent'),\n Slider = marker('Slider'), SliderButton = marker('SliderButton'), SliderPagination = marker('SliderPagination'), RecordText = marker('RecordText'), RecordContent = marker('RecordContent'), Media = marker('Media');\n\nfunction describe(node: ReactNode): any[] {\n return Children.toArray(node).flatMap(child => {\n if (!isValidElement(child)) return [{type: '#text', value: String(child)}];\n if (child.type === Fragment) return describe((child.props as any).children);\n const props = {...child.props as any};\n delete props.children;\n const type = typeof child.type === 'string' ? child.type : (child.type as any).kitName;\n if (!type) throw new Error('WordPress compiler: unsupported React component. Supply an adapter before using it in a portable section.');\n for (const [key, value] of Object.entries(props)) if (typeof value === 'function') throw new Error(`WordPress compiler: callback ${key} cannot be serialized`);\n return [{type, props, children: describe((child.props as any).children)}];\n });\n}\n\nexport function section(meta: any, View: () => ReactNode) {\n const template = describe(View());\n const staticTypes = new Set(['#text','Section','Text','Heading','Paragraphs','Image','Icon','Background','Buttons','SocialLinks','Button','Show','Toggle','Choice']);\n const isStatic = (nodes:any[]):boolean => nodes.every(node => (staticTypes.has(node.type) || /^[a-z]/.test(node.type)) && isStatic(node.children ?? []));\n return {name: 'site/' + meta.slug, title: meta.title, template, static: isStatic(template)};\n}\n"],
5
+ "mappings": "AAAA,SAAQ,UAAU,UAAU,sBAAqC;AAEjE,MAAM,SAAS,CAAC,SAAiB,OAAO,OAAO,CAAC,WAAgB,MAAM,EAAC,SAAS,KAAI,CAAC;AAC9E,MAAM,UAAU,OAAO,SAAS,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GACvF,aAAa,OAAO,YAAY,GAAG,QAAQ,OAAO,OAAO,GAAG,OAAO,OAAO,MAAM,GAChF,aAAa,OAAO,YAAY,GAAG,UAAU,OAAO,SAAS,GAAG,cAAc,OAAO,aAAa,GAAG,SAAS,OAAO,QAAQ,GAAG,OAAO,OAAO,MAAM,GACpJ,eAAe,OAAO,cAAc,GAAG,kBAAkB,OAAO,iBAAiB,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GAAG,aAAa,OAAO,YAAY,GAAG,cAAc,OAAO,aAAa,GAC7M,aAAa,OAAO,YAAY,GAAG,cAAc,OAAO,aAAa,GAAG,gBAAgB,OAAO,eAAe,GAAG,aAAa,OAAO,YAAY,GACjJ,cAAc,OAAO,aAAa,GAAG,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO,MAAM,GAAG,SAAS,OAAO,QAAQ,GAC3G,SAAS,OAAO,QAAQ,GAAG,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GACnG,YAAY,OAAO,WAAW,GAAG,gBAAgB,OAAO,eAAe,GAAG,mBAAmB,OAAO,kBAAkB,GAAG,mBAAmB,OAAO,kBAAkB,GACrK,SAAS,OAAO,QAAQ,GAAG,eAAe,OAAO,cAAc,GAAG,mBAAmB,OAAO,kBAAkB,GAAG,aAAa,OAAO,YAAY,GAAG,gBAAgB,OAAO,eAAe,GAAG,QAAQ,OAAO,OAAO;AAEvN,SAAS,SAAS,MAAwB;AACtC,SAAO,SAAS,QAAQ,IAAI,EAAE,QAAQ,WAAS;AAC3C,QAAI,CAAC,eAAe,KAAK,EAAG,QAAO,CAAC,EAAC,MAAM,SAAS,OAAO,OAAO,KAAK,EAAC,CAAC;AACzE,QAAI,MAAM,SAAS,SAAU,QAAO,SAAU,MAAM,MAAc,QAAQ;AAC1E,UAAM,QAAQ,EAAC,GAAG,MAAM,MAAY;AACpC,WAAO,MAAM;AACb,UAAM,OAAO,OAAO,MAAM,SAAS,WAAW,MAAM,OAAQ,MAAM,KAAa;AAC/E,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,2GAA2G;AACtI,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,EAAG,KAAI,OAAO,UAAU,WAAY,OAAM,IAAI,MAAM,gCAAgC,GAAG,uBAAuB;AAC7J,WAAO,CAAC,EAAC,MAAM,OAAO,UAAU,SAAU,MAAM,MAAc,QAAQ,EAAC,CAAC;AAAA,EAC5E,CAAC;AACL;AAEO,SAAS,QAAQ,MAAW,MAAuB;AACtD,QAAM,WAAW,SAAS,KAAK,CAAC;AAChC,QAAM,cAAc,oBAAI,IAAI,CAAC,SAAQ,WAAU,QAAO,WAAU,cAAa,SAAQ,QAAO,cAAa,WAAU,eAAc,UAAS,QAAO,UAAS,QAAQ,CAAC;AACnK,QAAM,WAAW,CAAC,UAAwB,MAAM,MAAM,WAAS,YAAY,IAAI,KAAK,IAAI,KAAK,SAAS,KAAK,KAAK,IAAI,MAAM,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC;AACvJ,SAAO,EAAC,MAAM,UAAU,KAAK,MAAM,OAAO,KAAK,OAAO,UAAU,QAAQ,SAAS,QAAQ,EAAC;AAC9F;",
6
6
  "names": []
7
7
  }
@@ -43,6 +43,17 @@ function button(array $value,?string $fallback=null,array $site=[]): string {
43
43
  }
44
44
  return tag('a',['href'=>esc_url($url),'class'=>$class,'data-modal-plan'=>$value['plan']??null],$label);
45
45
  }
46
+ function social_links(array $links, string $class = '', string $style = 'text'): string {
47
+ $labels = ['instagram'=>'Instagram', 'facebook'=>'Facebook', 'telegram'=>'Telegram', 'youtube'=>'YouTube', 'tiktok'=>'TikTok', 'linkedin'=>'LinkedIn'];
48
+ $html = '';
49
+ foreach ($labels as $network => $label) {
50
+ $url = $links[$network] ?? '';
51
+ if (is_string($url) && preg_match('~^https?://[^/]+~i', $url)) {
52
+ $html .= button(['text'=>$label, 'url'=>$url], $style);
53
+ }
54
+ }
55
+ return $html === '' ? '' : tag('div', ['class'=>$class], $html);
56
+ }
46
57
  /** Mirrors `flowPlacement` in frontend/kit/flow-layout.ts. */
47
58
  function flow_placement(int $grid,array $column,array $palette,int $max_col): array {
48
59
  $span=min($grid,max(1,(int)($column['span']??0)?:(int)($palette['span']??0)?:(int)round($grid/max(1,$max_col))));
@@ -161,6 +172,7 @@ function node(array $node,array $context): string {
161
172
  case 'Show':
162
173
  $visible=is_array($p['when'])?(bool)array_filter($p['when'],fn($key)=>trim(wp_strip_all_tags((string)($data[$key]??'')))!==''):(isset($p['is'])?($data[$p['when']]??null)===$p['is']:!empty($data[$p['when']]));return $visible?nodes($children,$context):'';
163
174
  case 'Button':return button(is_array($value)?$value:[],$p['style']??null,$site);
175
+ case 'SocialLinks':return social_links($site['settings']['socialLinks']??[],$class,$p['buttonStyle']??'text');
164
176
  case 'Buttons':$html='';foreach(is_array($value)?$value:[] as $i=>$button)$html.=button($button,$p['styles'][$i]??null,$site);return tag('div',['class'=>$class],$html);
165
177
  case 'Background':case 'Media':
166
178
  if(!$value)return '';if(is_string($value)||($value['type']??'image')==='image')return image(is_string($value)?$value:['url'=>$value['image']??$value['url']??'','alt'=>$value['alt']??''],$class?:'absolute inset-0 h-full w-full object-cover');
@@ -3,7 +3,10 @@ namespace SiteTheme\Kit;
3
3
  defined('ABSPATH') || exit;
4
4
  /** One host connection; generated entries belong to components and modules. */
5
5
  require_once __DIR__.'/adapters/next/runtime.php';
6
- require_once __DIR__.'/admin-ui/bootstrap.php';
7
- foreach (require __DIR__.'/generated/modules.php' as $entry) {
8
- require_once __DIR__.'/'.$entry;
6
+ if (function_exists('add_action')) {
7
+ require_once __DIR__.'/admin-ui/bootstrap.php';
8
+ foreach (require __DIR__.'/generated/modules.php' as $entry) {
9
+ require_once __DIR__.'/'.$entry;
10
+ }
9
11
  }
12
+ require_once __DIR__.'/wordpress/bootstrap.php';
@@ -0,0 +1,6 @@
1
+ type SocialLinksProps = {
2
+ className?: string;
3
+ buttonStyle?: string;
4
+ };
5
+ export declare function SocialLinks({ className, buttonStyle }: SocialLinksProps): import("react").JSX.Element | null;
6
+ export {};
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useSite } from "../../core/content/context.js";
4
+ import { buttonClasses } from "../../core/ui/button-appearance.js";
5
+ const networks = {
6
+ instagram: "Instagram",
7
+ facebook: "Facebook",
8
+ telegram: "Telegram",
9
+ youtube: "YouTube",
10
+ tiktok: "TikTok",
11
+ linkedin: "LinkedIn"
12
+ };
13
+ function SocialLinks({ className, buttonStyle = "text" }) {
14
+ const links = useSite().settings?.socialLinks ?? {};
15
+ const buttons = Object.entries(networks).flatMap(([network, label]) => {
16
+ const url = links[network];
17
+ if (typeof url !== "string" || !/^https?:\/\/[^/]+/i.test(url)) return [];
18
+ return /* @__PURE__ */ jsx("a", { href: url, className: buttonClasses("is-style-studio-" + buttonStyle), children: label }, network);
19
+ });
20
+ return buttons.length ? /* @__PURE__ */ jsx("div", { className, children: buttons }) : null;
21
+ }
22
+ export {
23
+ SocialLinks
24
+ };
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../components/social-links/index.tsx"],
4
+ "sourcesContent": ["'use client';\n\nimport { useSite } from '../../core/content/context.js';\nimport { buttonClasses } from '../../core/ui/button-appearance.js';\n\nconst networks = {\n instagram: 'Instagram',\n facebook: 'Facebook',\n telegram: 'Telegram',\n youtube: 'YouTube',\n tiktok: 'TikTok',\n linkedin: 'LinkedIn',\n};\n\ntype SocialLinksProps = {\n className?: string;\n buttonStyle?: string;\n};\n\nexport function SocialLinks({ className, buttonStyle = 'text' }: SocialLinksProps) {\n const links = useSite().settings?.socialLinks ?? {};\n const buttons = Object.entries(networks).flatMap(([network, label]) => {\n const url = links[network];\n if (typeof url !== 'string' || !/^https?:\\/\\/[^/]+/i.test(url)) return [];\n return <a key={network} href={url} className={buttonClasses(\"is-style-studio-\" + buttonStyle)}>{label}</a>;\n });\n\n return buttons.length ? <div className={className}>{buttons}</div> : null;\n}\n"],
5
+ "mappings": ";AAwBW;AAtBX,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAE9B,MAAM,WAAW;AAAA,EACf,WAAW;AAAA,EACX,UAAU;AAAA,EACV,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,UAAU;AACZ;AAOO,SAAS,YAAY,EAAE,WAAW,cAAc,OAAO,GAAqB;AACjF,QAAM,QAAQ,QAAQ,EAAE,UAAU,eAAe,CAAC;AAClD,QAAM,UAAU,OAAO,QAAQ,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS,KAAK,MAAM;AACrE,UAAM,MAAM,MAAM,OAAO;AACzB,QAAI,OAAO,QAAQ,YAAY,CAAC,qBAAqB,KAAK,GAAG,EAAG,QAAO,CAAC;AACxE,WAAO,oBAAC,OAAgB,MAAM,KAAK,WAAW,cAAc,qBAAqB,WAAW,GAAI,mBAAjF,OAAuF;AAAA,EACxG,CAAC;AAED,SAAO,QAAQ,SAAS,oBAAC,SAAI,WAAuB,mBAAQ,IAAS;AACvE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "id": "social-links",
3
+ "dependencies": []
4
+ }
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export { Media } from './components/media/index.js';
11
11
  export { Icon } from './components/icon/index.js';
12
12
  export { Button } from './components/button/index.js';
13
13
  export { Buttons } from './components/buttons/index.js';
14
+ export { SocialLinks } from './components/social-links/index.js';
14
15
  export { Background } from './components/background/index.js';
15
16
  export { Slider } from './components/slider/index.js';
16
17
  export { List } from './components/list/index.js';
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ import { Media } from "./components/media/index.js";
12
12
  import { Icon } from "./components/icon/index.js";
13
13
  import { Button } from "./components/button/index.js";
14
14
  import { Buttons } from "./components/buttons/index.js";
15
+ import { SocialLinks } from "./components/social-links/index.js";
15
16
  import { Background } from "./components/background/index.js";
16
17
  import { Slider } from "./components/slider/index.js";
17
18
  import { List } from "./components/list/index.js";
@@ -65,6 +66,7 @@ export {
65
66
  Slider,
66
67
  SliderButton,
67
68
  SliderPagination,
69
+ SocialLinks,
68
70
  Text,
69
71
  Toggle,
70
72
  collectFields,
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../index.tsx"],
4
- "sourcesContent": ["'use client';\nexport {AccordionItem,AccordionTrigger,AccordionContent} from './core/ui/disclosure.js';\nexport { SliderButton, SliderPagination } from './core/ui/slider.js';\nexport { RecordDate, RecordContent, RecordText, RecordEdit, RecordExcerpt, RecordImage, RecordIndex, RecordLink, RecordTitle } from './core/fields/render.js';\nexport { Section } from './components/section/index.js';\nexport { Heading } from './components/heading/index.js';\nexport { Text } from './components/text/index.js';\nexport { Paragraphs } from './components/paragraphs/index.js';\nexport { Image } from './components/image/index.js';\nexport { Gallery } from './components/gallery/index.js';\nexport { Media } from './components/media/index.js';\nexport { Icon } from './components/icon/index.js';\nexport { Button } from './components/button/index.js';\nexport { Buttons } from './components/buttons/index.js';\nexport { Background } from './components/background/index.js';\nexport { Slider } from './components/slider/index.js';\nexport { List } from './components/list/index.js';\nexport { Records } from './components/records/index.js';\nexport { Toggle } from './components/toggle/index.js';\nexport { Choice } from './components/choice/index.js';\nexport { Show } from './components/show/index.js';\nexport { Area } from './components/area/index.js';\nexport { Cols } from './components/cols/index.js';\nexport { Drag } from './components/drag/index.js';\nexport { Accordion } from './components/accordion/index.js';\nexport { collectFields } from './schema/index.js';\nexport type { SectionMeta } from './schema/index.js';\nexport { section } from './schema/index.js';\nexport { PricingPlans } from './components/pricing-plans/index.js';\nexport { ReviewsCarousel } from './components/reviews-carousel/index.js';\nexport { Form } from './components/forms/index.js';\n"],
5
- "mappings": ";AACA,SAAQ,eAAc,kBAAiB,wBAAuB;AAC9D,SAAS,cAAc,wBAAwB;AAC/C,SAAS,YAAY,eAAe,YAAY,YAAY,eAAe,aAAa,aAAa,YAAY,mBAAmB;AACpI,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAE9B,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,YAAY;",
4
+ "sourcesContent": ["'use client';\nexport {AccordionItem,AccordionTrigger,AccordionContent} from './core/ui/disclosure.js';\nexport { SliderButton, SliderPagination } from './core/ui/slider.js';\nexport { RecordDate, RecordContent, RecordText, RecordEdit, RecordExcerpt, RecordImage, RecordIndex, RecordLink, RecordTitle } from './core/fields/render.js';\nexport { Section } from './components/section/index.js';\nexport { Heading } from './components/heading/index.js';\nexport { Text } from './components/text/index.js';\nexport { Paragraphs } from './components/paragraphs/index.js';\nexport { Image } from './components/image/index.js';\nexport { Gallery } from './components/gallery/index.js';\nexport { Media } from './components/media/index.js';\nexport { Icon } from './components/icon/index.js';\nexport { Button } from './components/button/index.js';\nexport { Buttons } from './components/buttons/index.js';\nexport { SocialLinks } from './components/social-links/index.js';\nexport { Background } from './components/background/index.js';\nexport { Slider } from './components/slider/index.js';\nexport { List } from './components/list/index.js';\nexport { Records } from './components/records/index.js';\nexport { Toggle } from './components/toggle/index.js';\nexport { Choice } from './components/choice/index.js';\nexport { Show } from './components/show/index.js';\nexport { Area } from './components/area/index.js';\nexport { Cols } from './components/cols/index.js';\nexport { Drag } from './components/drag/index.js';\nexport { Accordion } from './components/accordion/index.js';\nexport { collectFields } from './schema/index.js';\nexport type { SectionMeta } from './schema/index.js';\nexport { section } from './schema/index.js';\nexport { PricingPlans } from './components/pricing-plans/index.js';\nexport { ReviewsCarousel } from './components/reviews-carousel/index.js';\nexport { Form } from './components/forms/index.js';\n"],
5
+ "mappings": ";AACA,SAAQ,eAAc,kBAAiB,wBAAuB;AAC9D,SAAS,cAAc,wBAAwB;AAC/C,SAAS,YAAY,eAAe,YAAY,YAAY,eAAe,aAAa,aAAa,YAAY,mBAAmB;AACpI,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAE9B,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,YAAY;",
6
6
  "names": []
7
7
  }
@@ -106,7 +106,7 @@ for (const name of ['tokens.css', 'admin.css']) {
106
106
  fs.copyFileSync('kit/admin-ui/' + name, output + '/admin-ui/' + name);
107
107
  }
108
108
  publishKitAssets(process.cwd(),path.resolve(output));
109
- fs.cpSync('public/assets', '../assets', { recursive: true });
109
+ if (fs.existsSync('public/assets')) fs.cpSync('public/assets', output + '/assets', { recursive: true });
110
110
  console.log('Gutenberg bundle and scoped Tailwind styles built.');
111
111
 
112
112
  // Preview images are authored beside sections; no CMS instance is required to display them.
@@ -13,7 +13,7 @@ const emitted=program.emit();
13
13
  const diagnostics=[...ts.getPreEmitDiagnostics(program),...emitted.diagnostics];
14
14
  if(diagnostics.length){console.error(ts.formatDiagnosticsWithColorAndContext(diagnostics,{getCanonicalFileName:f=>f,getCurrentDirectory:()=>root,getNewLine:()=> '\n'}));process.exit(1);}
15
15
  await build({entryPoints:config.fileNames.filter(file=>!file.endsWith('.d.ts')),outbase:root,outdir:output,format:'esm',platform:'neutral',target:'es2020',jsx:'automatic',bundle:false,sourcemap:true});
16
- const folders=['components','editor','core','ui','admin-ui','modules','adapters','hooks','styles','schema','shared','tooling'];
16
+ const folders=['components','editor','core','ui','admin-ui','modules','adapters','wordpress','hooks','styles','schema','shared','tooling'];
17
17
  for(const folder of folders){const source=path.join(root,folder);if(!fs.existsSync(source))continue;fs.cpSync(source,path.join(output,folder),{recursive:true,filter:file=>!(/\.tsx?$/.test(file))});}
18
18
  fs.copyFileSync(path.join(root,'bootstrap.php'),path.join(output,'bootstrap.php'));
19
19
  console.log(`Built ${config.fileNames.length} independent modules with declarations and server/assets sources.`);
@@ -1,43 +1,96 @@
1
1
  #!/usr/bin/env node
2
- import path from 'node:path';
3
- import {fileURLToPath,pathToFileURL} from 'node:url';
4
- import {prepareProject} from './prepare-project.mjs';
5
- const command=process.argv[2]??'help';
6
- const input=process.argv.slice(3),args=[];
7
- let root=process.cwd();
8
- for(let i=0;i<input.length;i++){
9
- if(input[i]==='--project'){if(!input[i+1])throw new Error('--project needs a path');root=input[++i];}
10
- else if(input[i].startsWith('--project='))root=input[i].slice(10);
11
- else args.push(input[i]);
2
+ import path from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+ import { prepareProject } from "./prepare-project.mjs";
5
+
6
+ const command = process.argv[2] ?? "help";
7
+ const input = process.argv.slice(3);
8
+ const args = [];
9
+ let root = process.cwd();
10
+ let blockOpt = "";
11
+
12
+ for (let i = 0; i < input.length; i++) {
13
+ if (input[i] === "--project") {
14
+ if (!input[i + 1]) throw new Error("--project needs a path");
15
+ root = input[++i];
16
+ } else if (input[i].startsWith("--project=")) {
17
+ root = input[i].slice(10);
18
+ } else if (input[i] === "--block") {
19
+ blockOpt = input[++i] ?? "";
20
+ } else if (input[i].startsWith("--block=")) {
21
+ blockOpt = input[i].slice(8);
22
+ } else {
23
+ args.push(input[i]);
24
+ }
12
25
  }
13
- root=path.resolve(root);
14
- const noBuild=args.includes('--no-build');
15
- const positional=args.filter(value=>!value.startsWith('--'));
16
- if(command==='prepare'){
17
- const result=prepareProject(root,{force:args.includes('--force')});
18
- console.log(`Prepared kit ${result.version} in ${result.directory}`);
19
- }else if(command==='dev'||command==='start'){
20
- const {runDev,runStart}=await import('./dev.mjs');
21
- await (command==='dev'?runDev:runStart)({root,args});
22
- }else if(['build:editor','build:wordpress','build:booking'].includes(command)){
23
- prepareProject(root);process.chdir(root);
24
- await import(pathToFileURL(path.join(root,'kit/tooling/'+command.replace(':','-')+'.mjs')).href);
25
- }else if(command==='create'||['create:component','create:section','create:layout'].includes(command)){
26
- prepareProject(root);
27
- const kind=command==='create'?positional[0]:command.split(':')[1];
28
- const slug=command==='create'?positional[1]:positional[0];
29
- const {createModule}=await import('./create-module.mjs');
30
- const result=createModule(root,kind,slug,{build:!noBuild});console.log(`Created ${result.name}\n${result.directory}`);
31
- }else if(command==='new:section'||(command==='new'&&positional[0]==='section')){
32
- prepareProject(root);
33
- const {createSection}=await import('./create-section.mjs');
34
- const result=createSection(root,command==='new'?positional[1]:positional[0]);console.log(`Created ${result.name}\n${result.directory}`);
35
- }else if(command==='render'||command==='render:module'){
36
- prepareProject(root);
37
- const {renderModule}=await import('./render-module.mjs');
38
- const output=renderModule(root,positional[0],{build:!noBuild,force:args.includes('--force'),stdout:args.includes('--stdout')});
39
- console.log(output);
40
- }else{
41
- console.log(`Usage: soinproduction-kit COMMAND [--project PATH]\n\n prepare [--force]\n dev [Next options] Dynamic port and optional editor watcher\n start [Next options] Dynamic production port\n create component NAME [--no-build]\n create section NAME [--no-build] Schema-based block\n create layout NAME [--no-build]\n new section NAME Declarative kit section\n render NAME [--stdout|--force] [--no-build]\n build:editor | build:wordpress | build:booking`);
42
- if(command!=='help')process.exitCode=1;
26
+
27
+ root = path.resolve(root);
28
+ const noBuild = args.includes("--no-build");
29
+ const positional = args.filter((value) => !value.startsWith("--"));
30
+
31
+ if (command === "init") {
32
+ const { initTheme } = await import("./init-theme.mjs");
33
+ const result = initTheme(root, { force: args.includes("--force") });
34
+ console.log(`Initialized theme in ${result.themeRoot} (kit ${result.prepared.version})`);
35
+ if (result.created.length) {
36
+ console.log("Created:\n " + result.created.join("\n "));
37
+ }
38
+ } else if (command === "prepare") {
39
+ const result = prepareProject(root, { force: args.includes("--force") });
40
+ console.log(`Prepared kit ${result.version} in ${result.directory}`);
41
+ } else if (command === "dev" || command === "start") {
42
+ const { runDev, runStart } = await import("./dev.mjs");
43
+ await (command === "dev" ? runDev : runStart)({ root, args });
44
+ } else if (["build:editor", "build:wordpress", "build:booking"].includes(command)) {
45
+ prepareProject(root);
46
+ process.chdir(root);
47
+ await import(pathToFileURL(path.join(root, "kit/tooling/" + command.replace(":", "-") + ".mjs")).href);
48
+ } else if (
49
+ command === "create:post-type" ||
50
+ (command === "create" && (positional[0] === "post-type" || positional[0] === "cpt"))
51
+ ) {
52
+ const slug = command === "create" ? positional[1] : positional[0];
53
+ const { createPostType } = await import("./create-post-type.mjs");
54
+ const result = createPostType(root, slug, {
55
+ collection: args.includes("--collection"),
56
+ force: args.includes("--force"),
57
+ block: blockOpt
58
+ });
59
+ console.log(`Created post type "${result.slug}" in ${result.file}`);
60
+ } else if (command === "create" || ["create:component", "create:section", "create:layout"].includes(command)) {
61
+ prepareProject(root);
62
+ const kind = command === "create" ? positional[0] : command.split(":")[1];
63
+ const slug = command === "create" ? positional[1] : positional[0];
64
+ const { createModule } = await import("./create-module.mjs");
65
+ const result = createModule(root, kind, slug, { build: !noBuild });
66
+ console.log(`Created ${result.name}\n${result.directory}`);
67
+ } else if (command === "new:section" || (command === "new" && positional[0] === "section")) {
68
+ prepareProject(root);
69
+ const { createSection } = await import("./create-section.mjs");
70
+ const result = createSection(root, command === "new" ? positional[1] : positional[0]);
71
+ console.log(`Created ${result.name}\n${result.directory}`);
72
+ } else if (command === "render" || command === "render:module") {
73
+ prepareProject(root);
74
+ const { renderModule } = await import("./render-module.mjs");
75
+ const output = renderModule(root, positional[0], {
76
+ build: !noBuild,
77
+ force: args.includes("--force"),
78
+ stdout: args.includes("--stdout")
79
+ });
80
+ console.log(output);
81
+ } else {
82
+ console.log(`Usage: soinproduction-kit COMMAND [--project PATH]
83
+
84
+ init [--force] Scaffold a new WordPress theme + kit config
85
+ prepare [--force] Sync kit runtime into frontend/kit
86
+ dev [Next options] Dynamic port and optional editor watcher
87
+ start [Next options] Dynamic production port
88
+ create post-type SLUG [--collection] [--block NAME] Generate CPT in inc/post-types/ + wire kit.config.json
89
+ create component NAME [--no-build]
90
+ create section NAME [--no-build] Schema-based block
91
+ create layout NAME [--no-build]
92
+ new section NAME Declarative kit section
93
+ render NAME [--stdout|--force] [--no-build]
94
+ build:editor | build:wordpress | build:booking`);
95
+ if (command !== "help") process.exitCode = 1;
43
96
  }
@@ -61,10 +61,9 @@ return ['id'=>'${slug}','group'=>'custom','name'=>'${name}','title'=>'${title}',
61
61
 
62
62
  const registry = path.join(root, 'src/blocks/registry.ts'),
63
63
  editor = path.join(root, 'src/blocks/editor-registry.ts'),
64
- php = path.resolve(root, '../inc/blocks/registry.php'),
65
64
  css = path.join(root, 'app/globals.css');
66
65
  const original = new Map(
67
- [registry, editor, php, css].map((f) => [f, fs.existsSync(f)?fs.readFileSync(f, 'utf8'):null])
66
+ [registry, editor, css].map((f) => [f, fs.existsSync(f)?fs.readFileSync(f, 'utf8'):null])
68
67
  );
69
68
  try {
70
69
  fs.mkdirSync(directory, { recursive: true });
@@ -0,0 +1,116 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+
4
+ const toTitle = (slug) =>
5
+ slug
6
+ .replace(/[-_]+/g, " ")
7
+ .replace(/\b\w/g, (c) => c.toUpperCase());
8
+
9
+ export function createPostType(projectRoot, rawSlug, options = {}) {
10
+ const slug = String(rawSlug || "")
11
+ .trim()
12
+ .toLowerCase()
13
+ .replace(/[^a-z0-9_]/g, "_");
14
+ if (!slug) {
15
+ throw new Error("Usage: soinproduction-kit create post-type <slug> [--collection] [--block site/card-name]");
16
+ }
17
+
18
+ const isfrontendDir = path.basename(projectRoot) === "frontend";
19
+ const themeRoot = isfrontendDir ? path.dirname(projectRoot) : projectRoot;
20
+ const frontendRoot = isfrontendDir ? projectRoot : path.join(projectRoot, "frontend");
21
+
22
+ const isCollection = Boolean(options.collection);
23
+ const blockName = options.block || `site/${slug.replace(/_/g, "-")}-card`;
24
+ const title = toTitle(slug);
25
+ const pluralKey = slug.endsWith("s") ? slug : `${slug}s`;
26
+ const rewriteSlug = pluralKey.replace(/_/g, "-");
27
+
28
+ const targetDir = path.join(themeRoot, "inc", "post-types");
29
+ fs.mkdirSync(targetDir, { recursive: true });
30
+ const targetFile = path.join(targetDir, `${slug}.php`);
31
+
32
+ if (fs.existsSync(targetFile) && !options.force) {
33
+ throw new Error(`Post type file already exists: ${targetFile} (use --force to overwrite)`);
34
+ }
35
+
36
+ const phpContent = isCollection
37
+ ? `<?php
38
+ namespace SiteTheme;
39
+ defined(\x27ABSPATH\x27) || exit;
40
+
41
+ add_action(\x27init\x27, function () {
42
+ \tregister_post_type(\x27${slug}\x27, [
43
+ \t\t\x27labels\x27 => [
44
+ \t\t\t\x27name\x27 => \x27${title}s\x27,
45
+ \t\t\t\x27singular_name\x27 => \x27${title}\x27,
46
+ \t\t],
47
+ \t\t\x27public\x27 => false,
48
+ \t\t\x27show_ui\x27 => true,
49
+ \t\t\x27show_in_rest\x27 => true,
50
+ \t\t\x27menu_icon\x27 => \x27dashicons-index-card\x27,
51
+ \t\t\x27supports\x27 => [\x27title\x27, \x27editor\x27, \x27page-attributes\x27, \x27custom-fields\x27],
52
+ \t\t\x27template\x27 => [[\x27${blockName}\x27, []]],
53
+ \t\t\x27template_lock\x27 => \x27all\x27,
54
+ \t]);
55
+ });
56
+
57
+ add_filter(\x27site_public_data\x27, function (array $data): array {
58
+ \t$data[\x27${pluralKey}\x27] = collection_records(\x27${slug}\x27);
59
+ \treturn $data;
60
+ });
61
+ `
62
+ : `<?php
63
+ namespace SiteTheme;
64
+ defined(\x27ABSPATH\x27) || exit;
65
+
66
+ add_action(\x27init\x27, function () {
67
+ \tregister_post_type(\x27${slug}\x27, [
68
+ \t\t\x27labels\x27 => [
69
+ \t\t\t\x27name\x27 => \x27${title}s\x27,
70
+ \t\t\t\x27singular_name\x27 => \x27${title}\x27,
71
+ \t\t],
72
+ \t\t\x27public\x27 => true,
73
+ \t\t\x27has_archive\x27 => false,
74
+ \t\t\x27rewrite\x27 => [\x27slug\x27 => \x27${rewriteSlug}\x27, \x27with_front\x27 => false],
75
+ \t\t\x27show_in_rest\x27 => true,
76
+ \t\t\x27menu_icon\x27 => \x27dashicons-portfolio\x27,
77
+ \t\t\x27supports\x27 => [\x27title\x27, \x27editor\x27, \x27excerpt\x27, \x27thumbnail\x27, \x27page-attributes\x27, \x27custom-fields\x27],
78
+ \t]);
79
+ });
80
+
81
+ add_filter(\x27site_public_data\x27, function (array $data): array {
82
+ \t$data[\x27${pluralKey}\x27] = cards(\x27${slug}\x27);
83
+ \treturn $data;
84
+ });
85
+ `;
86
+
87
+ fs.writeFileSync(targetFile, phpContent);
88
+
89
+ // Register in frontend/kit.config.json -> postTypes
90
+ const kitConfigPath = path.join(frontendRoot, "kit.config.json");
91
+ if (fs.existsSync(kitConfigPath)) {
92
+ const config = JSON.parse(fs.readFileSync(kitConfigPath, "utf8"));
93
+ const postTypes = new Set(Array.isArray(config.postTypes) ? config.postTypes : []);
94
+ postTypes.add(slug);
95
+ config.postTypes = [...postTypes];
96
+ fs.writeFileSync(kitConfigPath, JSON.stringify(config, null, 2) + "\n");
97
+ }
98
+
99
+ // Register in inc/bootstrap.php if present
100
+ const bootstrapPath = path.join(themeRoot, "inc", "bootstrap.php");
101
+ const relPath = `post-types/${slug}.php`;
102
+ if (fs.existsSync(bootstrapPath)) {
103
+ const boot = fs.readFileSync(bootstrapPath, "utf8");
104
+ if (!boot.includes(relPath)) {
105
+ const updated = boot.replace(
106
+ /(\[\s*(?:\x27[^\x27]+\x27\s*,?\s*)+)(\])/,
107
+ `$1\n\t\x27${relPath}\x27,\n$2`
108
+ );
109
+ if (updated !== boot) {
110
+ fs.writeFileSync(bootstrapPath, updated);
111
+ }
112
+ }
113
+ }
114
+
115
+ return { slug, file: targetFile, isCollection, pluralKey, blockName };
116
+ }