nextpress-core 1.0.0 → 1.0.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.
Files changed (182) hide show
  1. package/dist/acf-functions/core/acf-builder.d.ts +50 -0
  2. package/{lib/acf-functions/core/acf-builder.ts → dist/acf-functions/core/acf-builder.js} +17 -41
  3. package/dist/acf-functions/core/acf-component-autoloader.d.ts +11 -0
  4. package/{lib/acf-functions/core/acf-component-autoloader.ts → dist/acf-functions/core/acf-component-autoloader.js} +7 -13
  5. package/dist/acf-functions/core/acf-field-group-autoloader.d.ts +9 -0
  6. package/{lib/acf-functions/core/acf-field-group-autoloader.ts → dist/acf-functions/core/acf-field-group-autoloader.js} +4 -9
  7. package/dist/acf-functions/services/define-field-group.d.ts +8 -0
  8. package/{lib/acf-functions/services/define-field-group.ts → dist/acf-functions/services/define-field-group.js} +1 -1
  9. package/dist/acf-functions/services/define-layout.d.ts +8 -0
  10. package/{lib/acf-functions/services/define-layout.ts → dist/acf-functions/services/define-layout.js} +1 -1
  11. package/dist/acf-functions/services/map-fields/helpers/map-choice-object.d.ts +2 -0
  12. package/dist/acf-functions/services/map-fields/helpers/map-choice-object.js +18 -0
  13. package/dist/acf-functions/services/map-fields/map-fields.d.ts +18 -0
  14. package/{lib/acf-functions/services/map-fields/map-fields.ts → dist/acf-functions/services/map-fields/map-fields.js} +88 -124
  15. package/dist/entities/option/option.d.ts +19 -0
  16. package/{lib/entities/option/option.ts → dist/entities/option/option.js} +13 -20
  17. package/dist/entities/post/post.d.ts +50 -0
  18. package/dist/entities/post/post.js +184 -0
  19. package/dist/entities/term/term.d.ts +28 -0
  20. package/dist/entities/term/term.js +67 -0
  21. package/dist/entities/user/user.d.ts +27 -0
  22. package/dist/entities/user/user.js +74 -0
  23. package/dist/globals/entity-loader/entity-loader-base.d.ts +65 -0
  24. package/{lib/globals/entity-loader/entity-loader-base.ts → dist/globals/entity-loader/entity-loader-base.js} +10 -64
  25. package/dist/globals/entity-loader/option-loader.d.ts +15 -0
  26. package/dist/globals/entity-loader/option-loader.js +31 -0
  27. package/dist/globals/entity-loader/post-loader.d.ts +21 -0
  28. package/dist/globals/entity-loader/post-loader.js +28 -0
  29. package/dist/globals/entity-loader/term-loader.d.ts +21 -0
  30. package/dist/globals/entity-loader/term-loader.js +28 -0
  31. package/dist/globals/entity-loader/user-loader.d.ts +21 -0
  32. package/dist/globals/entity-loader/user-loader.js +28 -0
  33. package/dist/globals/get-field/get-field.d.ts +17 -0
  34. package/dist/globals/get-field/get-field.js +44 -0
  35. package/dist/globals/globals.d.ts +18 -0
  36. package/{lib/globals/globals.ts → dist/globals/globals.js} +3 -8
  37. package/dist/globals/nextpress-config/nextpress-config.d.ts +4 -0
  38. package/{lib/globals/nextpress-config/nextpress-config.ts → dist/globals/nextpress-config/nextpress-config.js} +0 -5
  39. package/dist/globals/queried-object/queried-object.d.ts +62 -0
  40. package/dist/globals/queried-object/queried-object.js +56 -0
  41. package/dist/repository/optionquery/option-query.d.ts +12 -0
  42. package/dist/repository/optionquery/option-query.js +20 -0
  43. package/dist/repository/postquery/post-query.d.ts +12 -0
  44. package/dist/repository/postquery/post-query.js +272 -0
  45. package/dist/repository/termquery/term-query.d.ts +11 -0
  46. package/dist/repository/termquery/term-query.js +213 -0
  47. package/dist/repository/userquery/user-query.d.ts +12 -0
  48. package/{lib/repository/userquery/user-query.ts → dist/repository/userquery/user-query.js} +75 -91
  49. package/dist/router/helpers.d.ts +14 -0
  50. package/{lib/router/helpers.ts → dist/router/helpers.js} +4 -4
  51. package/dist/router/nextpress-layout.d.ts +11 -0
  52. package/{lib/router/nextpress-layout.tsx → dist/router/nextpress-layout.js} +6 -23
  53. package/dist/router/nextpress-proxy.d.ts +8 -0
  54. package/{lib/router/nextpress-proxy.ts → dist/router/nextpress-proxy.js} +3 -15
  55. package/dist/router/nextpress-static-params.d.ts +9 -0
  56. package/{lib/router/nextpress-static-params.ts → dist/router/nextpress-static-params.js} +5 -17
  57. package/dist/router/router.d.ts +23 -0
  58. package/{lib/router/router.tsx → dist/router/router.js} +21 -29
  59. package/dist/router/routes/api/api-get-admin-bar.d.ts +8 -0
  60. package/{lib/router/routes/api/api-get-admin-bar.ts → dist/router/routes/api/api-get-admin-bar.js} +6 -8
  61. package/dist/router/routes/api/api-get-draft-mode.d.ts +8 -0
  62. package/{lib/router/routes/api/api-get-draft-mode.ts → dist/router/routes/api/api-get-draft-mode.js} +6 -15
  63. package/dist/router/routes/api/api-get-field-groups.d.ts +7 -0
  64. package/{lib/router/routes/api/api-get-field-groups.ts → dist/router/routes/api/api-get-field-groups.js} +6 -11
  65. package/dist/router/routes/api/api-post-revalidate.d.ts +7 -0
  66. package/{lib/router/routes/api/api-post-revalidate.ts → dist/router/routes/api/api-post-revalidate.js} +4 -6
  67. package/dist/router/routes/api/helpers.d.ts +8 -0
  68. package/{lib/router/routes/api/helpers.ts → dist/router/routes/api/helpers.js} +3 -4
  69. package/dist/router/routes/author-archive.d.ts +25 -0
  70. package/{lib/router/routes/author-archive.tsx → dist/router/routes/author-archive.js} +11 -37
  71. package/dist/router/routes/not-found-page.d.ts +15 -0
  72. package/{lib/router/routes/not-found-page.tsx → dist/router/routes/not-found-page.js} +3 -5
  73. package/dist/router/routes/post-index-page.d.ts +25 -0
  74. package/dist/router/routes/post-index-page.js +33 -0
  75. package/dist/router/routes/singular-page.d.ts +29 -0
  76. package/dist/router/routes/singular-page.js +51 -0
  77. package/dist/router/routes/site-front-page.d.ts +27 -0
  78. package/dist/router/routes/site-front-page.js +26 -0
  79. package/dist/router/routes/term-archive.d.ts +29 -0
  80. package/{lib/router/routes/term-archive.tsx → dist/router/routes/term-archive.js} +17 -45
  81. package/dist/services/get-menu.d.ts +13 -0
  82. package/{lib/services/get-menu.ts → dist/services/get-menu.js} +32 -56
  83. package/dist/services/get-theme-mods.d.ts +7 -0
  84. package/{lib/services/get-theme-mods.ts → dist/services/get-theme-mods.js} +4 -6
  85. package/dist/services/metadata/get-blogname.d.ts +6 -0
  86. package/{lib/services/metadata/get-blogname.ts → dist/services/metadata/get-blogname.js} +2 -2
  87. package/dist/services/metadata/get-favicon-url.d.ts +6 -0
  88. package/{lib/services/metadata/get-favicon-url.ts → dist/services/metadata/get-favicon-url.js} +4 -5
  89. package/dist/services/metadata/get-language-attribute.d.ts +6 -0
  90. package/{lib/services/metadata/get-language-attribute.ts → dist/services/metadata/get-language-attribute.js} +1 -1
  91. package/{lib/services/services.ts → dist/services/services.d.ts} +1 -5
  92. package/dist/services/services.js +3 -0
  93. package/dist/services/utilities/capitalise-first-letter.d.ts +7 -0
  94. package/{lib/services/utilities/capitalise-first-letter.ts → dist/services/utilities/capitalise-first-letter.js} +3 -2
  95. package/dist/services/utilities/esc-html.d.ts +7 -0
  96. package/{lib/services/utilities/esc-html.ts → dist/services/utilities/esc-html.js} +1 -3
  97. package/dist/services/utilities/get-date-time-formatter.d.ts +6 -0
  98. package/{lib/services/utilities/get-date-time-formatter.ts → dist/services/utilities/get-date-time-formatter.js} +6 -16
  99. package/dist/services/utilities/index.js +1 -0
  100. package/dist/services/utilities/kses-post.d.ts +7 -0
  101. package/{lib/services/utilities/kses-post.ts → dist/services/utilities/kses-post.js} +1 -2
  102. package/dist/services/utilities/process-url.d.ts +7 -0
  103. package/{lib/services/utilities/process-url.ts → dist/services/utilities/process-url.js} +3 -4
  104. package/dist/template-heirarchy/_autoloader/template-autoloader.d.ts +9 -0
  105. package/{lib/template-heirarchy/_autoloader/template-autoloader.ts → dist/template-heirarchy/_autoloader/template-autoloader.js} +9 -18
  106. package/dist/template-heirarchy/archive/archive.d.ts +16 -0
  107. package/{lib/template-heirarchy/archive/archive.tsx → dist/template-heirarchy/archive/archive.js} +7 -10
  108. package/dist/template-heirarchy/archive/author.d.ts +16 -0
  109. package/{lib/template-heirarchy/archive/author.tsx → dist/template-heirarchy/archive/author.js} +7 -10
  110. package/dist/template-heirarchy/archive/category.d.ts +16 -0
  111. package/{lib/template-heirarchy/archive/category.tsx → dist/template-heirarchy/archive/category.js} +7 -11
  112. package/dist/template-heirarchy/archive/posttypearchive.d.ts +24 -0
  113. package/{lib/template-heirarchy/archive/posttypearchive.tsx → dist/template-heirarchy/archive/posttypearchive.js} +7 -10
  114. package/dist/template-heirarchy/archive/tag.d.ts +16 -0
  115. package/{lib/template-heirarchy/archive/tag.tsx → dist/template-heirarchy/archive/tag.js} +7 -12
  116. package/dist/template-heirarchy/archive/taxonomy.d.ts +16 -0
  117. package/{lib/template-heirarchy/archive/taxonomy.tsx → dist/template-heirarchy/archive/taxonomy.js} +7 -10
  118. package/dist/template-heirarchy/home/home.d.ts +16 -0
  119. package/{lib/template-heirarchy/home/home.tsx → dist/template-heirarchy/home/home.js} +7 -10
  120. package/dist/template-heirarchy/index.d.ts +17 -0
  121. package/{lib/template-heirarchy/index.tsx → dist/template-heirarchy/index.js} +5 -9
  122. package/dist/template-heirarchy/not-found.tsx/not-found.d.ts +16 -0
  123. package/{lib/template-heirarchy/not-found.tsx/not-found.tsx → dist/template-heirarchy/not-found.tsx/not-found.js} +7 -10
  124. package/dist/template-heirarchy/page/page.d.ts +16 -0
  125. package/{lib/template-heirarchy/page/page.tsx → dist/template-heirarchy/page/page.js} +7 -10
  126. package/dist/template-heirarchy/page/posttype.d.ts +24 -0
  127. package/{lib/template-heirarchy/page/posttype.tsx → dist/template-heirarchy/page/posttype.js} +7 -11
  128. package/dist/template-heirarchy/page/single.d.ts +16 -0
  129. package/{lib/template-heirarchy/page/single.tsx → dist/template-heirarchy/page/single.js} +7 -10
  130. package/dist/template-heirarchy/page/singular.d.ts +16 -0
  131. package/{lib/template-heirarchy/page/singular.tsx → dist/template-heirarchy/page/singular.js} +7 -10
  132. package/dist/ui/render-attachment-image.d.ts +12 -0
  133. package/dist/ui/render-attachment-image.js +24 -0
  134. package/{lib/ui/render-components.tsx → dist/ui/render-components.d.ts} +4 -7
  135. package/dist/ui/render-components.js +7 -0
  136. package/dist/ui/render-the-admin-bar.d.ts +8 -0
  137. package/dist/ui/render-the-admin-bar.js +36 -0
  138. package/dist/ui/render-the-logo.d.ts +10 -0
  139. package/dist/ui/render-the-logo.js +16 -0
  140. package/dist/wpdb/wpdb.d.ts +3 -0
  141. package/{lib/wpdb/wpdb.ts → dist/wpdb/wpdb.js} +5 -9
  142. package/package.json +7 -3
  143. package/lib/acf-functions/services/map-fields/helpers/map-choice-object.ts +0 -20
  144. package/lib/acf-functions/types/acf-field-group.d.ts +0 -118
  145. package/lib/acf-functions/types/acf-field.d.ts +0 -2851
  146. package/lib/acf-functions/types/acf-layout.d.ts +0 -20
  147. package/lib/acf-functions/types/acf-values.d.ts +0 -4
  148. package/lib/acf-functions/types/components/field-props.d.ts +0 -189
  149. package/lib/acf-functions/types/components/nextpress-component.d.ts +0 -11
  150. package/lib/ambient.d.ts +0 -15
  151. package/lib/entities/common.d.ts +0 -30
  152. package/lib/entities/option/option.interface.d.ts +0 -8
  153. package/lib/entities/post/post.interface.d.ts +0 -72
  154. package/lib/entities/post/post.ts +0 -209
  155. package/lib/entities/term/term.interface.d.ts +0 -8
  156. package/lib/entities/term/term.ts +0 -82
  157. package/lib/entities/user/user.interface.d.ts +0 -10
  158. package/lib/entities/user/user.ts +0 -86
  159. package/lib/globals/entity-loader/entity-loader.d.ts +0 -50
  160. package/lib/globals/entity-loader/option-loader.ts +0 -56
  161. package/lib/globals/entity-loader/post-loader.ts +0 -59
  162. package/lib/globals/entity-loader/term-loader.ts +0 -59
  163. package/lib/globals/entity-loader/user-loader.ts +0 -60
  164. package/lib/globals/get-field/get-field.ts +0 -75
  165. package/lib/globals/nextpress-config/nextpress-config.interface.d.ts +0 -18
  166. package/lib/globals/queried-object/queried-object.ts +0 -124
  167. package/lib/repository/optionquery/option-query-args.d.ts +0 -21
  168. package/lib/repository/optionquery/option-query.ts +0 -29
  169. package/lib/repository/postquery/post-query-args.d.ts +0 -108
  170. package/lib/repository/postquery/post-query.ts +0 -281
  171. package/lib/repository/termquery/term-query-args.d.ts +0 -61
  172. package/lib/repository/termquery/term-query.ts +0 -243
  173. package/lib/repository/userquery/user-query-args.d.ts +0 -75
  174. package/lib/router/routes/post-index-page.tsx +0 -58
  175. package/lib/router/routes/singular-page.tsx +0 -78
  176. package/lib/router/routes/site-front-page.tsx +0 -51
  177. package/lib/router/types.d.ts +0 -9
  178. package/lib/ui/render-attachment-image.tsx +0 -29
  179. package/lib/ui/render-the-admin-bar.tsx +0 -79
  180. package/lib/ui/render-the-logo.tsx +0 -24
  181. package/lib/wpdb/wpdb.interface.d.ts +0 -171
  182. /package/{lib/services/utilities/index.ts → dist/services/utilities/index.d.ts} +0 -0
@@ -1,243 +0,0 @@
1
- import { QueryCreator } from "kysely";
2
- import { DB } from "../../wpdb/wpdb.interface";
3
- import { EntityQuery } from "../../globals/entity-loader/entity-loader";
4
- import { ITerm } from "../../entities/term/term.interface";
5
- import { wpdb } from "@/wpdb/wpdb";
6
-
7
- /**
8
- * Executes database queries to retrieve term IDs based on provided arguments.
9
- */
10
- export class TermQuery implements EntityQuery<ITerm>
11
- {
12
- public constructor(
13
- private args: TermQueryArgs
14
- ) {}
15
-
16
- public getCount() {
17
- return undefined;
18
- }
19
-
20
- public async getIds(): Promise<number[]> {
21
- let builder = wpdb as QueryCreator<any>;
22
-
23
- const isMultiple = this.args.multiple !== false;
24
-
25
- // -- Build CTEs --
26
- if (this.args.termId) {
27
- const termIds = Array.isArray(this.args.termId) ? this.args.termId : [this.args.termId];
28
- const baseQuery = (qb: any) => qb.selectFrom('wpTermTaxonomy')
29
- .select(['termId', 'parent'])
30
- .where((eb: any) => eb.or([
31
- eb('termId', 'in', termIds),
32
- eb('parent', 'in', termIds)
33
- ]));
34
-
35
- if (isMultiple) {
36
- builder = builder.withRecursive('included_branch_id', (qb) =>
37
- baseQuery(qb).unionAll(
38
- qb.selectFrom('wpTermTaxonomy as t')
39
- .select(['t.termId', 't.parent'])
40
- .innerJoin('included_branch_id as f', 'f.termId', 't.parent')
41
- )
42
- );
43
- } else {
44
- builder = builder.with('included_branch_id', baseQuery);
45
- }
46
- }
47
-
48
- if (this.args.termIdNot) {
49
- const termIds = Array.isArray(this.args.termIdNot) ? this.args.termIdNot : [this.args.termIdNot];
50
- const baseQuery = (qb: any) => qb.selectFrom('wpTermTaxonomy')
51
- .select(['termId', 'parent'])
52
- .where((eb: any) => eb.or([
53
- eb('termId', 'in', termIds),
54
- eb('parent', 'in', termIds)
55
- ]));
56
-
57
- if (isMultiple) {
58
- builder = builder.withRecursive('excluded_branch_id', (qb) =>
59
- baseQuery(qb).unionAll(
60
- qb.selectFrom('wpTermTaxonomy as t')
61
- .select(['t.termId', 't.parent'])
62
- .innerJoin('excluded_branch_id as f', 'f.termId', 't.parent')
63
- )
64
- );
65
- } else {
66
- builder = builder.with('excluded_branch_id', baseQuery);
67
- }
68
- }
69
-
70
- if (this.args.termName) {
71
- const names = Array.isArray(this.args.termName) ? this.args.termName : [this.args.termName];
72
- const baseQuery = (qb: any) => qb.selectFrom('wpTermTaxonomy')
73
- .innerJoin('wpTerms', 'wpTerms.termId', 'wpTermTaxonomy.termId')
74
- .select(['wpTermTaxonomy.termId', 'wpTermTaxonomy.parent'])
75
- .where('wpTerms.name', 'in', names);
76
-
77
- if (isMultiple) {
78
- builder = builder.withRecursive('included_branch_name', (qb) =>
79
- baseQuery(qb).unionAll(
80
- qb.selectFrom('wpTermTaxonomy as t')
81
- .select(['t.termId', 't.parent'])
82
- .innerJoin('included_branch_name as f', 'f.termId', 't.parent')
83
- )
84
- );
85
- } else {
86
- builder = builder.with('included_branch_name', baseQuery);
87
- }
88
- }
89
-
90
- if (this.args.termSlug) {
91
- const slugs = Array.isArray(this.args.termSlug) ? this.args.termSlug : [this.args.termSlug];
92
- const baseQuery = (qb: any) => qb.selectFrom('wpTermTaxonomy')
93
- .innerJoin('wpTerms', 'wpTerms.termId', 'wpTermTaxonomy.termId')
94
- .select(['wpTermTaxonomy.termId', 'wpTermTaxonomy.parent'])
95
- .where('wpTerms.slug', 'in', slugs);
96
-
97
- if (isMultiple) {
98
- builder = builder.withRecursive('included_branch_slug', (qb) =>
99
- baseQuery(qb).unionAll(
100
- qb.selectFrom('wpTermTaxonomy as t')
101
- .select(['t.termId', 't.parent'])
102
- .innerJoin('included_branch_slug as f', 'f.termId', 't.parent')
103
- )
104
- );
105
- } else {
106
- builder = builder.with('included_branch_slug', baseQuery);
107
- }
108
- }
109
-
110
- if (this.args.termSlugNot) {
111
- const slugs = Array.isArray(this.args.termSlugNot) ? this.args.termSlugNot : [this.args.termSlugNot];
112
- const baseQuery = (qb: any) => qb.selectFrom('wpTermTaxonomy')
113
- .innerJoin('wpTerms', 'wpTerms.termId', 'wpTermTaxonomy.termId')
114
- .select(['wpTermTaxonomy.termId', 'wpTermTaxonomy.parent'])
115
- .where('wpTerms.slug', 'in', slugs);
116
-
117
- if (isMultiple) {
118
- builder = builder.withRecursive('excluded_branch_slug', (qb) =>
119
- baseQuery(qb).unionAll(
120
- qb.selectFrom('wpTermTaxonomy as t')
121
- .select(['t.termId', 't.parent'])
122
- .innerJoin('excluded_branch_slug as f', 'f.termId', 't.parent')
123
- )
124
- );
125
- } else {
126
- builder = builder.with('excluded_branch_slug', baseQuery);
127
- }
128
- }
129
-
130
- // -- Begin Main SELECT Statement --
131
- let query = (builder as QueryCreator<DB>).selectFrom('wpTerms')
132
- .innerJoin('wpTermTaxonomy', 'wpTerms.termId', 'wpTermTaxonomy.termId');
133
-
134
- // -- Apply Filters (WHERE clauses) --
135
- if (this.args.taxonomy) {
136
- const taxonomies = Array.isArray(this.args.taxonomy) ? this.args.taxonomy : [this.args.taxonomy];
137
- query = query.where('wpTermTaxonomy.taxonomy', 'in', taxonomies);
138
- }
139
- if (this.args.taxonomyId) {
140
- const ids = Array.isArray(this.args.taxonomyId) ? this.args.taxonomyId : [this.args.taxonomyId];
141
- query = query.where('wpTermTaxonomy.termTaxonomyId', 'in', ids);
142
- }
143
-
144
- if (this.args.termId) query = query.where('wpTerms.termId', 'in', (qb: any) => qb.selectFrom('included_branch_id').select('termId'));
145
- if (this.args.termIdNot) query = query.where('wpTerms.termId', 'not in', (qb: any) => qb.selectFrom('excluded_branch_id').select('termId'));
146
- if (this.args.termName) query = query.where('wpTerms.termId', 'in', (qb: any) => qb.selectFrom('included_branch_name').select('termId'));
147
- if (this.args.termSlug) query = query.where('wpTerms.termId', 'in', (qb: any) => qb.selectFrom('included_branch_slug').select('termId'));
148
- if (this.args.termSlugNot) query = query.where('wpTerms.termId', 'not in', (qb: any) => qb.selectFrom('excluded_branch_slug').select('termId'));
149
- if (this.args.hideEmpty !== false) query = query.where('wpTermTaxonomy.count', '>', 0);
150
-
151
- if (this.args.parent !== undefined) {
152
- query = query.where('wpTermTaxonomy.parent', '=', this.args.parent);
153
- }
154
- if (this.args.childless) {
155
- query = query.where('wpTerms.termId', 'not in', (qb) =>
156
- qb.selectFrom('wpTermTaxonomy').select('wpTermTaxonomy.parent').where('wpTermTaxonomy.parent', '>', 0)
157
- );
158
- }
159
-
160
- if (this.args.search) {
161
- const searchStr = `%${this.args.search}%`;
162
- query = query.where((eb) => eb.or([
163
- eb('wpTerms.name', 'like', searchStr),
164
- eb('wpTerms.slug', 'like', searchStr)
165
- ]));
166
- }
167
- if (this.args.nameLike) {
168
- query = query.where('wpTerms.name', 'like', this.args.nameLike);
169
- }
170
- if (this.args.descriptionLike) {
171
- query = query.where('wpTermTaxonomy.description', 'like', this.args.descriptionLike);
172
- }
173
-
174
- if (this.args.path) {
175
- query = query.where((eb) => eb.exists(
176
- eb.selectFrom('wpTermmeta')
177
- .select('wpTerms.termId')
178
- .whereRef('wpTermmeta.termId', '=', 'wpTerms.termId')
179
- .where('wpTermmeta.metaKey', '=', '_nextpress_path')
180
- .where('wpTermmeta.metaValue', '=', this.args.path as string)
181
- ));
182
- }
183
-
184
- // -- Apply ORDER BY --
185
- const orderDirection = this.args.order === 'DESC' ? 'desc' : 'asc';
186
- const orderBy = this.args.orderBy || 'none';
187
-
188
- switch(orderBy) {
189
- case 'none': break;
190
- case 'term_id': query = query.orderBy('wpTerms.termId', orderDirection); break;
191
- case 'name': query = query.orderBy('wpTerms.name', orderDirection).orderBy('wpTerms.termId', orderDirection); break;
192
- case 'slug': query = query.orderBy('wpTerms.slug', orderDirection).orderBy('wpTerms.termId', orderDirection); break;
193
- case 'term_group': query = query.orderBy('wpTerms.termGroup', orderDirection).orderBy('wpTerms.termId', orderDirection); break;
194
- case 'description': query = query.orderBy('wpTermTaxonomy.description', orderDirection).orderBy('wpTerms.termId', orderDirection); break;
195
- case 'parent': query = query.orderBy('wpTermTaxonomy.parent', orderDirection).orderBy('wpTerms.termId', orderDirection); break;
196
- case 'count': query = query.orderBy('wpTermTaxonomy.count', orderDirection).orderBy('wpTerms.termId', orderDirection); break;
197
- default: query = query.orderBy('wpTerms.name', orderDirection).orderBy('wpTerms.termId', orderDirection); break;
198
- }
199
-
200
- // -- Apply LIMIT & OFFSET --
201
- const limit = this.args.number ?? 0;
202
- if (limit > 0) {
203
- query = query.limit(limit);
204
- }
205
-
206
- const offsetAmount = this.args.offset ?? 0;
207
- if (offsetAmount > 0) {
208
- query = query.offset(offsetAmount);
209
- }
210
-
211
- if (this.args.metaQuery) {
212
- let dynamicQuery: any = query;
213
-
214
- for (let metaQuery of this.args.metaQuery) {
215
- const uniqueAlias = `meta_${metaQuery.as}`;
216
-
217
- dynamicQuery = dynamicQuery.leftJoin(`wpTermmeta as ${uniqueAlias}`, (join: any) =>
218
- join
219
- .onRef(`${uniqueAlias}.termId`, '=', 'wpTerms.termId')
220
- .on(`${uniqueAlias}.metaKey`, '=', metaQuery.metaKey)
221
- )
222
- .select(`${uniqueAlias}.metaValue as ${metaQuery.as}`);
223
- }
224
-
225
- query = dynamicQuery;
226
- }
227
-
228
- try {
229
- if (isMultiple) {
230
- return (await query
231
- .select('wpTerms.termId')
232
- .groupBy('wpTerms.termId')
233
- .execute()).map((res: any) => res.termId);
234
- } else {
235
- return (await query
236
- .select('wpTerms.termId')
237
- .execute()).map((res: any) => res.termId);
238
- }
239
- } catch (error: any) {
240
- throw new Error(`WPTermQuery: Cannot get terms: ${error.message}`, { cause: error });
241
- }
242
- }
243
- }
@@ -1,75 +0,0 @@
1
- /**
2
- * Defines the arguments for querying users.
3
- * Maps standard WordPress WP_User_Query parameters.
4
- */
5
- interface UserQueryArgs {
6
- /** User ID, or array of user IDs, to match when querying terms. */
7
- userId?: number | number[];
8
- /** An array of user IDs to exclude. Default empty array. */
9
- userIdsNotIn?: number[];
10
- /** The user nicename. Default empty. */
11
- nicename?: string;
12
- /** An array of nicenames to include. Default empty array. */
13
- nicenameIn?: string[];
14
- /** An array of nicenames to exclude. Default empty array. */
15
- nicenameNotIn?: string[];
16
- /** The user display name. Default empty. */
17
- displayName?: string;
18
- /** An array of display names to include. Default empty array. */
19
- displayNameIn?: string[];
20
- /** An array of display names to exclude. Default empty array. */
21
- displayNameNotIn?: string[];
22
- /** The user login. Default empty. */
23
- login?: string;
24
- /** An array of logins to include. Default empty array. */
25
- loginIn?: string[];
26
- /** An array of logins to exclude. Default empty array. */
27
- loginNotIn?: string[];
28
- /** An array of role names. Matched users must have at least one of these roles. Default empty array. */
29
- roleIn?: string[];
30
- /** An array of role names that users must match to be included in results. Note that this is an inclusive list: users must match *each* role. Default empty. */
31
- roleAnd?: string[];
32
- /** An array of role names to exclude. Users matching one or more of these roles will not be included in results. Default empty array. */
33
- roleNotIn?: string[];
34
- /** Search keyword. Searches for possible string matches on columns. */
35
- search?: string;
36
- /** Array of column names to be searched. */
37
- search_columns?: ('ID' | 'userLogin' | 'userEmail' | 'userUrl' | 'userNicename' | 'displayName')[]
38
- /** Field(s) to order terms by. Default 'none'. */
39
- orderBy?:
40
- | 'ID'
41
- | 'name'
42
- | 'login'
43
- | 'nicename'
44
- | 'first_name'
45
- | 'last_name'
46
- | 'email'
47
- | 'registered'
48
- | 'post_count'
49
- | 'count'
50
- | 'none'
51
- | string;
52
- /** Designates ascending or descending order of users. Accepts 'ASC', 'DESC'. Default 'ASC'. */
53
- order?: 'ASC' | 'DESC';
54
- /** Number of users to offset in retrieved results. Can be used in conjunction with pagination. Default 0. */
55
- offset?: number;
56
- /** Number of users to limit the query for. Value -1 (all) is supported. Default -1. */
57
- usersPerPage?: number;
58
- /** Show users that would show up on page. */
59
- page?: number;
60
- /** Show all posts (true) or paginate (false). Default false. */
61
- noPaging?: boolean;
62
- /** Whether to skip counting the total rows found. Default false. */
63
- noFoundRows?: boolean;
64
- /** Pass an array of post types to filter results to users who have published posts in those post types. `true` is an alias for all public post types. */
65
- hasPublishedPosts?: boolean | string[];
66
- /** Meta query */
67
- metaQuery?: {
68
- /** Meta key */
69
- metaKey: string,
70
- /** Variable name to save result to */
71
- as: string
72
- }[]
73
- /** Whether to get multiple, default false */
74
- multiple?: bool
75
- }
@@ -1,58 +0,0 @@
1
- import { MetadataResult, RouteProps, TemplateResult } from "../types";
2
- import { getPageNumber } from "../helpers";
3
- import { queriedObjectState } from "@/globals/globals";
4
- import { HomeMetadata, HomeTemplate } from "@/template-heirarchy/home/home";
5
-
6
- /**
7
- * Resolves the post index page (blog home) route and maps it to the template hierarchy to return Metadata.
8
- * * Routing Behavior:
9
- * - Unconditionally routes to `HomeMetadata`.
10
- *
11
- * @param {{ path: string[], metadata: true }} props - Route properties requesting metadata.
12
- * @returns {Promise<MetadataResult>} The generated metadata.
13
- */
14
- export function PostIndexPage(props: { path: string[], metadata: true }): Promise<MetadataResult>;
15
-
16
- /**
17
- * Resolves the post index page (blog home) route and maps it to the template hierarchy to return a Template.
18
- * * Routing Behavior:
19
- * - Unconditionally routes to `HomeTemplate`.
20
- *
21
- * @param {{ path: string[], metadata?: false }} props - Route properties requesting a template.
22
- * @returns {Promise<TemplateResult>} The rendered template component.
23
- */
24
- export function PostIndexPage(props: { path: string[], metadata?: false }): Promise<TemplateResult>;
25
-
26
- /**
27
- * Core implementation for the post index page route.
28
- * Fetches the paginated list of all published posts and updates the queried object state.
29
- *
30
- * @param {RouteProps} props - Route properties including the path array and metadata flag.
31
- * @returns {Promise<MetadataResult | TemplateResult>} The metadata or template result based on the hierarchy.
32
- */
33
- export async function PostIndexPage({ path, metadata = false }: RouteProps) {
34
- const page = getPageNumber(path) || 1;
35
- const postsPerPage = Number(await getOption('posts_per_page')) ?? 10;
36
-
37
- const postIds = await postLoader.findAndPrime({
38
- noFoundRows: false,
39
- noPaging: false,
40
- postType: 'post',
41
- page: page,
42
- postsPerPage: postsPerPage,
43
- postStatus: 'publish',
44
- orderBy: 'date'
45
- });
46
-
47
- const currentQueriedObject = {
48
- posts: postIds.ids,
49
- page,
50
- pageCount: postIds.count / postsPerPage
51
- }
52
-
53
- const state = queriedObjectState();
54
- state.currentState = currentQueriedObject;
55
-
56
- return metadata ? await HomeMetadata() : <HomeTemplate/>;
57
- }
58
-
@@ -1,78 +0,0 @@
1
- import { MetadataResult, RouteProps, TemplateResult } from "../types";
2
- import { PostIndexPage } from "./post-index-page";
3
- import { getPageNumber } from "../helpers";
4
- import { notFound } from "next/navigation";
5
- import { queriedObjectState } from "@/globals/globals";
6
- import { PageMetadata, PageTemplate } from "@/template-heirarchy/page/page";
7
- import { SingleMetadata, SingleTemplate } from "@/template-heirarchy/page/single";
8
-
9
- /**
10
- * Resolves the singular page route and maps it to the template hierarchy to return Metadata.
11
- * * Routing Behavior:
12
- * - If the post_type is 'post', it routes to `SingleMetadata`.
13
- * - If the post ID matches the 'page_for_posts' option, it delegates routing to `PostIndexPage`.
14
- * - Otherwise, it defaults to routing to `PageMetadata`.
15
- *
16
- * @param {{ path: string[], metadata: true }} props - Route properties requesting metadata.
17
- * @returns {Promise<MetadataResult>} The generated metadata.
18
- */
19
- export function SingularPage(props: { path: string[], metadata: true }): Promise<MetadataResult>;
20
-
21
- /**
22
- * Resolves the singular page route and maps it to the template hierarchy to return a Template.
23
- * * Routing Behavior:
24
- * - If the post_type is 'post', it routes to `SingleTemplate`.
25
- * - If the post ID matches the 'page_for_posts' option, it delegates routing to `PostIndexPage`.
26
- * - Otherwise, it defaults to routing to `PageTemplate`.
27
- *
28
- * @param {{ path: string[], metadata?: false }} props - Route properties requesting a template.
29
- * @returns {Promise<TemplateResult>} The rendered template component.
30
- */
31
- export function SingularPage(props: { path: string[], metadata?: false }): Promise<TemplateResult>;
32
-
33
- /**
34
- * Core implementation for the singular page/post route.
35
- * Resolves the path to a specific post ID and updates the queried object state.
36
- *
37
- * @param {RouteProps} props - Route properties including the path array and metadata flag.
38
- * @returns {Promise<MetadataResult | TemplateResult>} The metadata or template result based on the hierarchy.
39
- * @throws {Error} Throws a Next.js notFound error if the path does not match any post or page.
40
- */
41
- export async function SingularPage({ path, metadata = false }: RouteProps) {
42
- let page = getPageNumber(path);
43
- if (page) {
44
- path = path.slice(0, -2);
45
- } else {
46
- page = 1;
47
- }
48
-
49
- const postId = (await postLoader.findAndPrime({
50
- path: `/${path.join('/')}`,
51
- multiple: false,
52
- noFoundRows: true,
53
- noPaging: true,
54
- ignoreStickyPosts: true,
55
- })).ids[0];
56
- if (!postId) notFound();
57
-
58
- const post = await getPost(postId) ?? notFound()
59
-
60
- const postType = post.postType
61
-
62
- const currentQueriedObject = {
63
- objectType: 'post',
64
- posts: [postId]
65
- }
66
- const state = queriedObjectState();
67
- state.currentState = currentQueriedObject;
68
-
69
- if (postType === 'post') {
70
- return metadata ? await SingleMetadata() : <SingleTemplate/>;
71
- }
72
- if (post.ID !== Number(await getOption('page_for_posts'))) {
73
- return metadata ? await PageMetadata() : <PageTemplate/>;
74
- } else {
75
- return metadata ? await PostIndexPage({path, metadata: true}) : <PostIndexPage path={path}/>
76
- }
77
- }
78
-
@@ -1,51 +0,0 @@
1
- import { queriedObjectState } from "@/globals/globals";
2
- import { MetadataResult, RouteProps, TemplateResult } from "../types";
3
- import { PostIndexPage } from "./post-index-page";
4
- import { PageMetadata, PageTemplate } from "@/template-heirarchy/page/page";
5
-
6
- /**
7
- * Resolves the site front page route and maps it to the template hierarchy to return Metadata.
8
- * * Routing Behavior:
9
- * - If a static page is set as the homepage ('page_on_front'), it routes to `PageMetadata`.
10
- * - If no static page is set, it delegates routing to `PostIndexPage`.
11
- *
12
- * @param {{ path: string[], metadata: true }} props - Route properties requesting metadata.
13
- * @returns {Promise<MetadataResult>} The generated metadata.
14
- */
15
- export function SiteFrontPage(props: { path: string[], metadata: true }): Promise<MetadataResult>;
16
-
17
- /**
18
- * Resolves the site front page route and maps it to the template hierarchy to return a Template.
19
- * * Routing Behavior:
20
- * - If a static page is set as the homepage ('page_on_front'), it routes to `PageTemplate`.
21
- * - If no static page is set, it delegates routing to `PostIndexPage`.
22
- *
23
- * @param {{ path: string[], metadata?: false }} props - Route properties requesting a template.
24
- * @returns {Promise<TemplateResult>} The rendered template component.
25
- */
26
- export function SiteFrontPage(props: { path: string[], metadata?: false }): Promise<TemplateResult>;
27
-
28
- /**
29
- * Core implementation for the site front page (root) route.
30
- * Checks for a configured static front page and updates the queried object state.
31
- *
32
- * @param {RouteProps} props - Route properties including the path array and metadata flag.
33
- * @returns {Promise<MetadataResult | TemplateResult>} The metadata or template result based on the hierarchy.
34
- */
35
- export async function SiteFrontPage({ path, metadata = false }: RouteProps) {
36
- const homepageId = Number(await getOption('page_on_front'));
37
-
38
- if (homepageId) {
39
- const currentQueriedObject = {
40
- objectType: 'post',
41
- posts: [homepageId]
42
- }
43
-
44
- const state = queriedObjectState();
45
- state.currentState = currentQueriedObject;
46
-
47
- return metadata ? await PageMetadata() : <PageTemplate/>;
48
- } else {
49
- return metadata ? await PostIndexPage({path, metadata: true}) : <PostIndexPage path={path}/>
50
- }
51
- }
@@ -1,9 +0,0 @@
1
- import { Metadata } from "next";
2
-
3
- type TemplateResult = JSX.Element;
4
- type MetadataResult = Metadata;
5
-
6
- type RouteProps = {
7
- path: string[];
8
- metadata?: boolean;
9
- }
@@ -1,29 +0,0 @@
1
- import { ClassValue } from "clsx";
2
- import Image from "next/image";
3
- import { ComponentPropsWithoutRef } from "react";
4
-
5
- type Props = Omit<ComponentPropsWithoutRef<typeof Image>, "src" | "alt" | "height" | "width"> & {
6
- attachmentId: number;
7
- className?: ClassValue;
8
- };
9
-
10
- /**
11
- * Renders a WordPress media attachment using the Next.js Image component.
12
- */
13
- export async function RenderAttachmentImage({ attachmentId, className, ...rest }: Props) {
14
- const image = await getPost(attachmentId);
15
- if (!image) return;
16
-
17
- const { src, alt, height, width } = image.imageAttributes;
18
-
19
- return (
20
- <Image
21
- src={src || ''}
22
- alt={alt || ''}
23
- height={height}
24
- width={width}
25
- className={className}
26
- {...rest}
27
- />
28
- );
29
- }
@@ -1,79 +0,0 @@
1
- "use client"
2
- import { useEffect, useState } from "react";
3
- import { usePathname } from "next/navigation";
4
- import Script from "next/script";
5
- import { wpKsesPost } from "@/services/utilities/kses-post";
6
-
7
- type Props = {
8
- loggedInUserId?: number
9
- }
10
-
11
- type AdminBarResponse = {
12
- html: string,
13
- assets: {
14
- css: {
15
- admin_bar: string,
16
- dashicons: string
17
- },
18
- js: {
19
- admin_bar: string
20
- }
21
- }
22
- }
23
-
24
- /**
25
- * Renders the WordPress admin bar for authenticated administrators browsing the Next.js frontend.
26
- */
27
- export async function RenderTheAdminBar({ loggedInUserId }: Props) {
28
- const [adminBar, setAdminBar] = useState<AdminBarResponse | null>(null);
29
- const [isMounted, setIsMounted] = useState(false);
30
-
31
- const path = usePathname();
32
-
33
- useEffect(() => {
34
- fetch(`/api/admin-bar?user_id=${loggedInUserId}&path=${encodeURIComponent(path)}`)
35
- .then((request) => {
36
- if (!request.ok) {
37
- throw new Error(`Failed to fetch admin bar: ${request.status}`);
38
- }
39
- return request.json();
40
- })
41
- .then((response) => {
42
- setAdminBar(response);
43
- setTimeout(() => setIsMounted(true), 50);
44
- })
45
- .catch((error) => {
46
- console.error("Failed to load admin bar", error.message);
47
- })
48
- }, [loggedInUserId, path]);
49
-
50
- if (!adminBar) {
51
- return null;
52
- }
53
-
54
- return (
55
- <>
56
- <link
57
- rel="stylesheet"
58
- href={adminBar.assets.css.admin_bar}
59
- precedence="high"
60
- />
61
- <link
62
- rel="stylesheet"
63
- href={adminBar.assets.css.dashicons}
64
- precedence="high"
65
- />
66
- <Script src={adminBar.assets.js.admin_bar}/>
67
-
68
- <div
69
- className={`fixed top-0 left-0 right-0 transform transition-all duration-300 ease-in-out ${
70
- isMounted
71
- ? "scale-y-100"
72
- : "scale-y-0"
73
- }`}
74
- >
75
- {wpKsesPost(adminBar.html)}
76
- </div>
77
- </>
78
- );
79
- }
@@ -1,24 +0,0 @@
1
- import { getThemeMods } from "@/services/get-theme-mods";
2
- import { getBlogname } from "@/services/metadata/get-blogname";
3
- import { RenderAttachmentImage } from "./render-attachment-image";
4
-
5
- type Props = {
6
- className?: string
7
- }
8
-
9
- /**
10
- * Renders the custom site logo defined in the WordPress Customizer.
11
- *
12
- * Fallback: Renders the text-based Site Title if no custom logo is assigned in WordPress.
13
- */
14
- export async function RenderTheLogo({ className }: Props) {
15
- const logoId = Number(await getThemeMods('custom_logo')) ?? 0;
16
-
17
- return (
18
- <div className={className}>
19
- {logoId ?
20
- <RenderAttachmentImage className="h-full w-full object-contain object-center" attachmentId={logoId} sizes="512px"/>
21
- : <span className="text-4xl font-bold">{await getBlogname()}</span>}
22
- </div>
23
- )
24
- }