Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1 custom post type #17

Merged
merged 10 commits into from
Apr 15, 2024
Merged

v1 custom post type #17

merged 10 commits into from
Apr 15, 2024

Conversation

bph
Copy link
Collaborator

@bph bph commented Apr 12, 2024

Blueprint

  • create folder
  • Add a file to create a plugin that adds a custom post type.
  • activate plugin

Enable the user of playground to create posts with certain custom post type, and create single post and archive templates for this post type.

Also props to @ryanwelcher

It's v1

@adamziel
Copy link
Contributor

Let's rename book.txt to book.php since it's a PHP file.

add missing /trunk/ in URL

Co-authored-by: Adam Zielinski <[email protected]>
'label' => __( 'Book', 'gbt' ),
'description' => __( 'Books', 'gbt' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', excerpt, featured_image),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting PHP Fatal error: Uncaught Error: Undefined constant "excerpt" here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I made changes after I tested it myself. 🤦‍♀️ I removed supports excerpt and featured image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should work now.

@bph
Copy link
Collaborator Author

bph commented Apr 12, 2024

@adamziel The reason I used books.txt was that my test directory is in an /wp-content/uploads directory of a WordPress site, that will try processing the php file and run into a 403 error. That doesn't happen when referencing a txt. file.

I tested it all again, and all seems to be fixed now.

@bph bph self-assigned this Apr 12, 2024
bph and others added 3 commits April 12, 2024 16:47
correction of referenced file

Co-authored-by: Adam Zielinski <[email protected]>
remove files not belonging to this branch.
@adamziel adamziel merged commit 608e0da into trunk Apr 15, 2024
@adamziel
Copy link
Contributor

Perfect, thank you!

@bph bph deleted the custom-post branch April 15, 2024 11:16
reimic pushed a commit to reimic/blueprints-library-ci that referenced this pull request Jun 11, 2024
…ma (#23)

Solves the Blueprint parsing problem as follows:

* JSON Schema is the source of truth for the Blueprint data structure
* Model classes are generated from JSON Schema
* Input Validation is done against the JSON Schema
* Mapping validated input into model instances is indirectly done based on the JSON Schema

## Summary of the approach

We use [Janephp](https://github.com/janephp/janephp/) to infer the PHP model class structure from the JSON schema

We then use Jane's output to generate PHP code using [Nette PHP generator](https://github.com/nette/php-generator):

* Model classes
* Interfaces for groups of related classes: `StepDefinitionInterface`, `ResourceDefinitionInterface`.
* Interface resolution map for the [JsonMapper library](https://jsonmapper.net/).
* PHP docstrings with more accurate types than Jane to guide the mapping process

From there, the data pipeline looks as follows:

1. Parse raw JSON
2. Validate it with Opis
3. Map it into PHP models using JsonMapper

Or, if you're consuming the PHP API directly:

1. Create Model instances
2. Validate them with Opis

## Remaining work

- [ ] Solve merge conflicts

## Rationale

Parsing and mapping JSON [in TypeScript is a simple problem, but in PHP it's surprisingly involved](WordPress/blueprints#13 (comment)). This PR combines three previously explored approaches into a single pipeline:

* WordPress/blueprints#17
* WordPress/blueprints#19
* WordPress/blueprints#21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants