This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #371 from WebDevStudios/feature/369-code-reorganiz…
…ation-wp-functions Feature/369 code reorganization wp functions
- Loading branch information
Showing
95 changed files
with
286 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# /functions/next-api/ | ||
|
||
Functions for interacting with our <a href="https://nextjs.org/docs/api-routes/introduction">Next.js API Routes</a>, defined in `pages/api/`. | ||
|
||
Subfolders should correspond to API routes, e.g., `/functions/next-api/wordpress/` matches with `/pages/api/wordpress/`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# /functions/next-api/wordpress/ | ||
|
||
Functions for interacting with our WordPress-specific <a href="https://nextjs.org/docs/api-routes/introduction">Next.js API Routes</a>, defined in `/pages/api/wordpress/`. |
2 changes: 1 addition & 1 deletion
2
...-api/wordpress/archive/getArchivePosts.js → ...-api/wordpress/archive/getArchivePosts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../wordpress/comments/processPostComment.js → .../wordpress/comments/processPostComment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# /functions/wordpress/ | ||
|
||
Functions for interacting with the <a href="https://www.wpgraphql.com/docs/introduction/">WordPress GraphQL API</a> or processing WordPress data. |
2 changes: 1 addition & 1 deletion
2
lib/wordpress/users/loginUser.js → functions/wordpress/auth/loginUser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/wordpress/users/refreshAuthToken.js → functions/wordpress/auth/refreshAuthToken.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/wordpress/users/registerUser.js → functions/wordpress/auth/registerUser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/wordpress/comments/insertPostComment.js → ...s/wordpress/comments/insertPostComment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
functions/gravityForms/getGfFormDefaults.js → ...rdpress/gravityForms/getGfFormDefaults.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...gravityForms/getGfFormValidationSchema.js → ...gravityForms/getGfFormValidationSchema.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
lib/wordpress/media/getMediaByID.js → functions/wordpress/media/getMediaByID.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
6 changes: 2 additions & 4 deletions
6
lib/wordpress/menus/getMenus.js → functions/wordpress/menus/getMenus.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 4 additions & 23 deletions
27
lib/wordpress/_global/getFrontendPage.js → ...ns/wordpress/postTypes/getFrontendPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import processPostTypeQuery from '@/functions/wordpress/postTypes/processPostTypeQuery' | ||
import headlessConfigPageQuerySeo from '@/lib/wordpress/_config/headlessConfigPageQuerySeo' | ||
|
||
/** | ||
* Retrieve single page set via Headless Config. | ||
* | ||
* @author WebDevStudios | ||
* @param {string} page Custom page name in config. | ||
* @return {object} Object containing Apollo client instance and post data or error object. | ||
*/ | ||
export default async function getHeadlessConfigPage(page) { | ||
// Retrieve page query. | ||
const query = headlessConfigPageQuerySeo?.[page]?.query ?? null | ||
|
||
const data = await processPostTypeQuery('page', page, query) | ||
|
||
// Add custom SEO if missing. | ||
if (!data?.post?.seo) { | ||
data.post = { | ||
...data?.post, | ||
seo: { | ||
title: `${headlessConfigPageQuerySeo[page]?.title ?? ''} - ${ | ||
data.defaultSeo?.openGraph?.siteName ?? '' | ||
}`, | ||
description: headlessConfigPageQuerySeo[page]?.description ?? '', | ||
canonical: `${data.defaultSeo?.openGraph?.url ?? ''}/${page}` | ||
} | ||
} | ||
} | ||
|
||
return data | ||
} |
25 changes: 5 additions & 20 deletions
25
lib/wordpress/_global/getPostTypeArchive.js → ...wordpress/postTypes/getPostTypeArchive.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
lib/wordpress/_global/getPostTypeById.js → ...ns/wordpress/postTypes/getPostTypeById.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...rdpress/_global/getPostTypeStaticPaths.js → ...press/postTypes/getPostTypeStaticPaths.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
32fb2e2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: