Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Add adventure custom post type #33

Merged
merged 10 commits into from
Apr 12, 2018
Merged

Add adventure custom post type #33

merged 10 commits into from
Apr 12, 2018

Conversation

DavidCramer
Copy link
Contributor

Adds the adventure custom post type.

Fixes #7

@DavidCramer
Copy link
Contributor Author

Still requires the additional metafields setup to capture the extra data, but otherwise as a basis for the custom post type definition, this is ready for review.

cc @ThierryA @westonruter

@DavidCramer DavidCramer changed the title [WIP] Add adventure custom post type Add adventure custom post type Apr 6, 2018
Copy link
Contributor

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

For the meta fields, we'll want to use either Gutenberg blocks that use postmeta as their attribute sources.

'show_ui' => true,
'show_in_nav_menus' => true,
'show_in_menu' => true,
'show_in_admin_bar' => true,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is missing show_in_rest which is required for Gutenberg.

*/
add_theme_support( 'post-thumbnails' );

// Image Sizes.
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a phpdoc comment to describe the filter.

@DavidCramer
Copy link
Contributor Author

Thanks @westonruter - I have addressed the changes you requested. Feel free to review when you have time.

@miina
Copy link
Contributor

miina commented Apr 9, 2018

@DavidCramer On the adventure post type -- did you also try editing in Gutenberg? When I create a new Adventure, publish it, and then change a setting (for example the content) and try to save again, I’m getting some errors + the title disappears from the view. Looks similar to behavior that got fixed here, however that was supposedly happening only if the CPT doesn't support title.

Wondering if that's something that only I'm experiencing or if it's an issue with Gutenberg.
screen shot 2018-04-09 at 2 48 48 pm

If you have a moment could you try if it works OK for you?

miina added a commit that referenced this pull request Apr 9, 2018
*
* @package WPAMPTheme
*/
class AMP_Travel_CTP {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like a typo, should probably be _CPT instead of _CTP.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops yes, will fix

@DavidCramer
Copy link
Contributor Author

@miina I haven't tested yet in Gutenberg yet as this was just the definition of the type. But I think I should put it back to WIP and get that aspect sorted.

@DavidCramer DavidCramer changed the title Add adventure custom post type [WIP] Add adventure custom post type Apr 9, 2018
@DavidCramer
Copy link
Contributor Author

@westonruter - I initially did this just as the CPT definition. However, as @miina pointed out, it's not working yet with Gutenberg. I'll do more tests and clean it up first, then will let you know when you can review it again.

@DavidCramer
Copy link
Contributor Author

@westonruter @ThierryA this is ready for review now. @miina I have tested with Gutenberg and it behaves as expected.

@DavidCramer DavidCramer changed the title [WIP] Add adventure custom post type Add adventure custom post type Apr 11, 2018
@DavidCramer DavidCramer mentioned this pull request Apr 11, 2018
4 tasks
@ThierryA ThierryA requested a review from kienstra April 11, 2018 11:52
Use AMP_Travel_Theme::instantiate_classes().
And change AMP_Travel_CPT::__contstruct to init().
This uses the bootstrap mechanism in the develop branch.
@kienstra kienstra self-assigned this Apr 11, 2018
Copy link
Contributor

@kienstra kienstra left a comment

Choose a reason for hiding this comment

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

Almost Ready, A Few Points

Hi @DavidCramer,
Thanks for registering the new 'adventure' post type. There are a few points here, one of which might not need any action.

'description' => __( 'Adventure Custom Post Type for travel theme.', 'travel' ),
'public' => true,
'exclude_from_search' => true,
'publicly_queryable' => true,
Copy link
Contributor

@kienstra kienstra Apr 11, 2018

Choose a reason for hiding this comment

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

The following arguments have the default value, and are not needed:

  • publicly_queryable
  • show_ui
  • show_in_nav_menus
  • show_in_menu
  • show_in_admin_bar
  • capability_type
  • hierarchical
  • query_var
  • can_export
  • rest_controller_class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kienstra - yup, I'll remove them.

'280x158',
'240x135',
'160x90',
'122x67',
Copy link
Contributor

@kienstra kienstra Apr 11, 2018

Choose a reason for hiding this comment

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

Are all of these image sizes needed?

You know more about the specifics than I do. But it seems excessive to create 15 image sizes for every image uploaded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kienstra - no idea. but it's a good point. I took these from the ampconf theme as a starting point. I'll reduce it down to what I think should be needed for the current blocks, etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is something that we should revisit. But I'm going to merge this PR to unblock other PRs.

@kienstra kienstra assigned DavidCramer and unassigned kienstra Apr 11, 2018
kienstra added a commit that referenced this pull request Apr 12, 2018
These look to have been from PR #33.
And they might be valid.
But defer the discussion of those to that PR.
We might need custom image sizes,
so continue this conversation.
But several PRs depend on this PR,
so it would help to merge it.
In that class, make all functions public.
Change __construct() to init(),
and move the requiring of class-amp-travel-cpt.php
to AMP_Travel_Theme::includes().
Thanks to David for creating that file.
This keeps all of the logic of the plugin files self-sufficient.
functions.php wil only have to require class-amp-travel-theme.php.
And call amp_travel_theme()->init().
And its instantiation.
That class isn't in this branch.
Use the new includes() method to require it.
And instantiate and init() it in:
instantiate_classes().
Copy link
Contributor

@kienstra kienstra left a comment

Choose a reason for hiding this comment

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

Approved

If it's alright, I applied the 2 review points I made with this commit.

@DavidCramer, could you please look at whether there are any more image sizes needed here? I deleted the add_image_size() call for now, to merge this.

@kienstra kienstra merged commit c420080 into develop Apr 12, 2018
@kienstra kienstra deleted the feature/7-declare-cpt branch April 12, 2018 22:11
@DavidCramer
Copy link
Contributor Author

Thanks @kienstra. Can always add additional sizes if needed later. It's all good.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants