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

Possible Issue with Removing Taxonomies #784

Closed
MonsterKing opened this issue Aug 4, 2021 · 1 comment
Closed

Possible Issue with Removing Taxonomies #784

MonsterKing opened this issue Aug 4, 2021 · 1 comment
Assignees
Labels
type:bug Something isn't working.

Comments

@MonsterKing
Copy link

Describe the bug
I realize this could be me... :-) I am trying to preventing taxonomies (all -- categories, tags, etc) from "pulling" into our site. I'm not trying to filter available posts by taxonomy, I just don't want taxonomies to "import" (for lack of better term).

This is what I am working with:

function eecs_exclude_taxonomies($post_array) {
$post_array['terms'] = array();
return $post_array;
}
add_filter('dt_pull_post_args', 'eecs_exclude_taxonomies', 10, 3);

To test this, I have done two things:

  1. In the function above, I print the post array (print_r($post_array);) and exit the function (just to make sure the filter properly emptied the terms item. It did, yet terms are still being imported. So...
  2. I added some test code to: includes/classes/ExternalConnections/WordPressExternalConnection.php

I added:
$value = apply_filters( 'dt_pull_post_args', $post_array, $item_array['remote_post_id'], $post, $this );
print_r($value);
exit;

at line 437. The output did not include terms (hurray!). Yet, still, when I let the process continue, terms are imported.

I noticed the in the WordpressExternalConnection.php file, at line 460, shows this:
if ( ! empty( $post_array['terms'] ) ) {
\Distributor\Utils\set_taxonomy_terms( $new_post, $post_array['terms'] );
}

The conditional seems to check the original $post_array -- not that which has results from the filter ($new_post), however, I think that $new_post is just the insert ID. If I change the above to:

		if ( ! empty( $value['terms'] ) ) {
			\Distributor\Utils\set_taxonomy_terms( $new_post, $post_array['terms'] );
		}

Terms do not import -- which is exactly what I want to have happen (ideally without changing the core files).

Steps to Reproduce

  1. I think this can only be reproduced by adding the function I show above under "Describe the Bug."

Expected behavior

I want terms to not import.

Screenshots

Environment information

  • Device: PC
  • OS: Windows 10
  • Browser and version: Chrome, but irrelevant
  • WordPress version: 5.8
  • Plugins and version: Distributor Stable 1.6.4
  • Theme and version: Custom
  • Site Health Info:

Additional context

@MonsterKing MonsterKing added the type:bug Something isn't working. label Aug 4, 2021
@faisal-alvi faisal-alvi self-assigned this Jun 22, 2022
@faisal-alvi
Copy link
Member

faisal-alvi commented Jun 22, 2022

Hi @MonsterKing - thanks for reaching out.

Fortunately, we have introduced a new filter dt_pull_post_terms (#800) to control the terms processing. Please add the following code to your destination site:

add_filter( 'dt_pull_post_terms', '__return_false' );

This will bypass the terms processing and the terms will not be synced/pulled. Read more here.

With this, closing the ticket as the issue seems resolved with the given code, please feel free to re-open if you find any issues or need more clarification.

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
None yet
Development

No branches or pull requests

2 participants