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

dt_available_pull_post_types Filter Not Working #1193

Open
1 task done
turtlepod opened this issue Feb 15, 2024 · 0 comments
Open
1 task done

dt_available_pull_post_types Filter Not Working #1193

turtlepod opened this issue Feb 15, 2024 · 0 comments
Labels
type:bug Something isn't working.

Comments

@turtlepod
Copy link
Member

Describe the bug

There's a filter to add non-existing post type to the pull option.
https://10up.github.io/distributor/dt_available_pull_post_types.html

But it's not working because this filter results is compared to the distributable_post_types() function which uses post_type_exists check.

Summary:

  • There's a filter to add non-existing post type.
  • But we check it using post_type_exists
  • It's always getting removed.

dt_available_pull_post_types Filter:
https://github.com/10up/distributor/blob/develop/includes/utils.php#L274-L283

	$pull_post_types = apply_filters( 'dt_available_pull_post_types', $post_types, $remote_post_types, $local_post_types, $connection, $type );

	if ( ! empty( $pull_post_types ) ) {
		$post_types = array();
		foreach ( $pull_post_types as $post_type ) {
			if ( in_array( $post_type['slug'], $distributable_post_types, true ) ) {
				$post_types[] = $post_type;
			}
		}
	}

distributable_post_types Function:
https://github.com/10up/distributor/blob/develop/includes/utils.php#L325

$post_types = array_filter( $post_types, 'post_type_exists' );

Steps to Reproduce

  • There's a filter to add non-existing post type.
  • But we check it using post_type_exists
  • It's always getting removed.

Screenshots, screen recording, code snippet

n/a - see description

Environment information

WP 6.4.3 / Distributor 2.0.3

WordPress information

WP 6.4.3 / Distributor 2.0.3

Code of Conduct

  • I agree to follow this project's Code of Conduct
@turtlepod turtlepod added the type:bug Something isn't working. label Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working.
Projects
Status: Incoming
Development

No branches or pull requests

1 participant