10up / distributor

Share content between your websites.
https://distributorplugin.com
GNU General Public License v2.0
628 stars 155 forks source link

`dt_available_pull_post_types` Filter Not Working #1193

Open turtlepod opened 6 months ago

turtlepod commented 6 months ago

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:

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

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