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

Fix/906 Distributable post types made consistent #907

Merged
merged 8 commits into from
Jul 21, 2022
Merged

Conversation

faisal-alvi
Copy link
Member

Description of the Change

  • This PR reverts the changes made in Enhancement/860 Removed Built-in post types for External Connections + Added a new filter. #898.
  • Removes the function get_excluded_post_types_from_permission_list.
  • Removes a filter dt_excluded_post_types_from_permission_list.
  • Modifies the distributable_post_types function. Added a new parameter $output, which supports returning the result as per the given type of output.
  • In that function, the following post types are excluded from the result by default.
                 'attachment',
		'nav_menu_item',
		'wp_block',
		'wp_navigation',
		'wp_template',
		'wp_template_part',
		'dt_ext_connection',
		'dt_subscription'

Closes #906

How to test the Change

  1. Create a new connection or edit an existing one.
  2. See the list under the “Post types permissions” title.
  3. You won’t find any of these:
    1. Media
    2. Navigation Menu Items
    3. Reusable blocks
    4. Templates
    5. Templates Parts
    6. Navigation Menus

Changelog Entry

Added - Distributable post types made consistent
Removed - The filter dt_excluded_post_types_from_permission_list is removed.

Credits

Props @faisal-alvi

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@faisal-alvi faisal-alvi added this to the 1.7.0 milestone Jul 15, 2022
@faisal-alvi faisal-alvi self-assigned this Jul 15, 2022
Copy link
Collaborator

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

I've added a few notes.

I've changed the search slightly in distributable_post_types() but need to figure out whether show_in_rest should be a requirement for internal connections.

I'll dig in to the code.

includes/utils.php Outdated Show resolved Hide resolved
includes/utils.php Outdated Show resolved Hide resolved
includes/external-connection-cpt.php Outdated Show resolved Hide resolved
includes/utils.php Outdated Show resolved Hide resolved
includes/utils.php Outdated Show resolved Hide resolved
@peterwilsoncc
Copy link
Collaborator

Sorry for the double post but I noticed a number of places in which get_post_types() is been called rather than using the utility function.

The main one I suspect should use the utility function is

$post_types = get_post_types( [ 'public' => true ], 'objects' );

The appearances in includes/rest-api.php appear to be OK as it's altering all the post types that can be shown in the rest api.

@peterwilsoncc
Copy link
Collaborator

peterwilsoncc commented Jul 21, 2022

I think this is good to go for the changes that can go in to 1.7.0

@faisal-alvi I've made the following changes since taking the PR https://github.com/10up/distributor/pull/907/files/28878153e576b45b6d7ee99d5c362676d4e36a3d..6c3e2557b6d34ecbeedc732032ae81a59875a0ab

I've created #912 for some further follow up in 2.0.0 -- the changes I think are still needed don't affect any of the UI.

I've asked Darin to review as this now includes my code.

@peterwilsoncc peterwilsoncc requested review from a team and dkotter and removed request for a team July 21, 2022 03: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.

Consistently determine if a post type is distributable.
3 participants